/* ITOS Interfaces - Identidade visual ITOS */
:root {
    --azul-escuro: #004E74;
    --azul-medio: #0099CC;
    --azul-marinho: #006699;
    --laranja: #FF6600;
    --laranja-hover: #E55A00;
    --branco: #FFFFFF;
    --cinza-claro: #F5F5F5;
    --cinza-medio: #E0E0E0;
    --cinza-texto: #666666;
    --erro: #CC3333;
    --sucesso: #2E7D32;
}

* {
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', system-ui, sans-serif;
    margin: 0;
    padding: 0;
    background: var(--cinza-claro);
    color: var(--azul-escuro);
    min-height: 100vh;
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.main-content {
    flex: 1;
    min-height: 0;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    overflow-y: auto;
    overflow-x: hidden;
}

/* Menu superior */
.top-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--azul-escuro);
    color: var(--branco);
    padding: 0 16px;
    height: 40px;
    flex-shrink: 0;
}

.nav-logo {
    color: var(--branco);
    text-decoration: none;
    font-weight: 700;
    font-size: 14px;
}

.nav-logo:hover {
    color: var(--cinza-claro);
}

.nav-menu {
    display: flex;
    gap: 4px;
    align-items: center;
}

.nav-link {
    color: rgba(255,255,255,0.9);
    text-decoration: none;
    padding: 5px 12px;
    border-radius: 5px;
    font-size: 13px;
    font-weight: 500;
    transition: background 0.2s, color 0.2s;
}

.nav-link:hover {
    background: rgba(255,255,255,0.15);
    color: var(--branco);
}

.nav-link.active {
    background: var(--laranja);
    color: var(--branco);
}

.nav-user {
    display: flex;
    align-items: center;
    gap: 12px;
}

.nav-user-name {
    font-size: 12px;
    opacity: 0.95;
}

.nav-logout {
    font-size: 12px;
    padding: 4px 10px;
}

@media (max-width: 600px) {
    .top-nav {
        flex-wrap: wrap;
        height: auto;
        padding: 8px 12px;
        gap: 6px;
    }
    .nav-menu {
        order: 3;
        width: 100%;
        justify-content: flex-start;
    }
}

/* Flash messages */
.flash-messages {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
    max-width: 400px;
}

.flash {
    padding: 12px 20px;
    margin-bottom: 8px;
    border-radius: 8px;
    font-size: 14px;
}

.flash-error {
    background: #ffebee;
    color: var(--erro);
    border: 1px solid var(--erro);
}

.flash-success {
    background: #e8f5e9;
    color: var(--sucesso);
    border: 1px solid var(--sucesso);
}

/* Layout - uso total da largura */
.container {
    width: 100%;
    max-width: none;
    padding: 20px 24px;
}

.card {
    background: var(--branco);
    border-radius: 12px;
    padding: 24px 28px;
    box-shadow: 0 2px 8px rgba(0,78,116,0.08);
    width: 100%;
}

/* Header */
.header {
    width: 100%;
    background: var(--azul-escuro);
    color: var(--branco);
    padding: 8px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.header h1 {
    margin: 0;
    font-size: 16px;
}

.header-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.2s;
}

.btn-primary {
    background: var(--laranja);
    color: var(--branco);
}

.btn-primary:hover {
    background: var(--laranja-hover);
}

.btn-secondary {
    background: var(--azul-medio);
    color: var(--branco);
}

.btn-secondary:hover {
    background: var(--azul-escuro);
}

.btn-danger {
    background: var(--erro);
    color: var(--branco);
}

.btn-danger:hover {
    background: #AA2222;
}

.btn-outline {
    background: transparent;
    color: var(--azul-medio);
    border: 1px solid var(--azul-medio);
}

.btn-outline:hover {
    background: var(--cinza-claro);
}

.btn-sm {
    padding: 6px 14px;
    font-size: 12px;
}

/* Forms */
.form-group {
    margin-bottom: 20px;
}

.form-row {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    align-items: flex-end;
    margin-bottom: 16px;
}

.form-row .form-group {
    margin-bottom: 0;
}

.form-row.form-row-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

.form-row.form-row-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

@media (max-width: 768px) {
    .form-row.form-row-2,
    .form-row.form-row-3 {
        grid-template-columns: 1fr;
    }
}

.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 6px;
    font-size: 13px;
}

.form-control {
    width: 100%;
    max-width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--cinza-medio);
    border-radius: 8px;
    font-size: 14px;
    background: var(--branco);
}

.form-control:focus {
    outline: none;
    border-color: var(--azul-medio);
}

/* Checkbox */
.checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.checkbox-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.checkbox-item input {
    width: 18px;
    height: 18px;
    accent-color: var(--azul-medio);
}

/* Empresa checkbox (lista de empresas do tenant) */
.empresa-checkbox {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    background: var(--cinza-claro);
    margin: 6px 0;
    border-radius: 6px;
    cursor: pointer;
}

.empresa-checkbox:hover {
    background: var(--cinza-medio);
}

.empresa-checkbox input {
    width: 18px;
    height: 18px;
    margin-right: 12px;
    accent-color: var(--azul-medio);
    flex-shrink: 0;
}

.empresa-checkbox span {
    font-size: 14px;
}

.checkbox-gerador-row {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

/* Login page */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.login-card {
    width: 100%;
    max-width: 520px;
}

.login-card .logo {
    text-align: center;
    margin-bottom: 15px;
}

.login-card .logo img {
    max-width: 180px;
    height: auto;
}

.login-card h2 {
    text-align: center;
    color: var(--azul-escuro);
    margin: 0 0 8px 0;
    font-size: 24px;
}

.login-card .subtitle {
    text-align: center;
    color: var(--azul-escuro);
    font-size: 14px;
    margin-bottom: 25px;
}

.login-card .btn {
    width: 100%;
    max-width: 100%;
    padding: 14px;
    font-size: 16px;
}

.login-card .link-cadastro {
    display: block;
    text-align: center;
    margin-top: 15px;
    color: var(--azul-medio);
    text-decoration: none;
    font-size: 14px;
}

.login-card .link-cadastro:hover {
    text-decoration: underline;
}

/* Panel */
.panel-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}

.panel-card {
    background: var(--cinza-claro);
    border-radius: 8px;
    padding: 20px;
    text-decoration: none;
    color: inherit;
    display: block;
    transition: background 0.2s;
}

.panel-card:hover {
    background: var(--cinza-medio);
}

.panel-card h3 {
    margin: 0 0 6px 0;
    font-size: 16px;
}

.panel-card p {
    margin: 0;
    font-size: 13px;
    color: var(--cinza-texto);
}

.panel-card.disabled {
    opacity: 0.6;
    cursor: default;
}

.panel-card.disabled:hover {
    background: var(--cinza-claro);
}

/* Admin tabs */
.tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
}

.tabs a {
    padding: 10px 20px;
    background: var(--azul-medio);
    color: var(--branco);
    text-decoration: none;
    border-radius: 8px;
    font-size: 14px;
}

.tabs a:hover {
    background: var(--azul-escuro);
}

.tabs a.active {
    background: var(--azul-escuro);
}

/* List cards */
.list-card {
    background: var(--cinza-claro);
    border-radius: 8px;
    padding: 16px 20px;
    margin-bottom: 10px;
}

.list-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 8px;
}

.list-card h3 {
    margin: 0;
    font-size: 14px;
}

.list-card-actions {
    display: flex;
    gap: 8px;
}

.list-card-meta {
    font-size: 12px;
    color: var(--cinza-texto);
}

.section-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 24px;
    margin-bottom: 20px;
}

/* Empresa block (tenant form) */
.empresa-block {
    background: var(--cinza-claro);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 12px;
}

.empresa-block-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.empresa-block-header {
    font-weight: 600;
    font-size: 13px;
}

.empresa-fields {
    display: grid;
    gap: 12px;
}

.empresa-fields .form-control {
    max-width: 100%;
}

/* Section cards */
.section-card {
    background: var(--cinza-claro);
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
}

.section-card h3 {
    margin: 0 0 15px 0;
    font-size: 16px;
    color: var(--azul-escuro);
}

/* Tabs */
.tab-link {
    padding: 10px 20px;
    background: var(--cinza-medio);
    cursor: pointer;
    border-radius: 8px 8px 0 0;
    font-size: 14px;
}

.tab-link.active {
    background: var(--azul-medio);
    color: var(--branco);
}

.tab-content {
    display: none;
    padding: 20px 0;
}

.tab-content.active {
    display: block;
}

/* Grid table */
.grid-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.grid-table th, .grid-table td {
    padding: 8px 10px;
    border: 1px solid var(--cinza-medio);
    text-align: left;
}

.grid-table th {
    background: var(--azul-escuro);
    color: var(--branco);
}

.grid-table input, .grid-table select {
    width: 100%;
    min-width: 80px;
    padding: 6px 8px;
    font-size: 12px;
    background: var(--branco);
    border: 1px solid var(--cinza-medio);
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: var(--branco);
    padding: 25px;
    border-radius: 12px;
    max-width: 450px;
    width: 90%;
}

.modal-content h3 {
    margin-top: 0;
}

/* Placeholder */
.placeholder-page {
    padding: 30px;
}

.placeholder-page h2 {
    color: var(--azul-escuro);
    margin-bottom: 10px;
}

.placeholder-page p {
    color: var(--cinza-texto);
    margin-bottom: 20px;
}

/* Rodapé do sistema - sempre visível em todas as telas */
.site-footer {
    flex-shrink: 0;
    text-align: center;
    padding: 6px 16px;
    font-size: 11px;
    color: var(--cinza-texto);
    background: var(--cinza-medio);
}

.site-footer a {
    color: var(--azul-medio);
    text-decoration: none;
}

.site-footer a:hover {
    text-decoration: underline;
}

/* Página de lotes - layout compacto, altura total */
.page-lotes {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

.page-lotes .header {
    flex-shrink: 0;
    padding: 4px 16px;
}

.page-lotes .header h1 {
    font-size: 14px;
}

.page-lotes .container-lotes {
    flex: 1;
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 4px 12px;
    overflow-y: auto;
    min-height: 0;
}

.page-lotes .card-lotes {
    display: flex;
    flex-direction: column;
    min-height: 0;
    padding: 8px 16px;
}

.page-lotes .card-lotes-title {
    margin: 0 0 10px 0;
    font-size: 18px;
}

.page-lotes .form-buscar-lote {
    margin-bottom: 6px;
}

.page-lotes .form-buscar-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: flex-end;
}

.page-lotes .card-lotes-hr {
    margin: 6px 0;
}

.page-lotes .form-lote-main {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

.page-lotes .form-lote-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 2px 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.page-lotes .form-lote-layout-30-70 {
    display: flex;
    flex-direction: row;
    gap: 8px;
    align-items: stretch;
}

.page-lotes .form-lote-col-esq {
    flex: 0 0 30%;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.page-lotes .form-lote-col-esq .form-row-3 {
    grid-template-columns: 1fr;
}

.page-lotes .form-lote-col-esq .form-row-2 {
    grid-template-columns: 1fr;
}

.page-lotes .form-lote-col-dir {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

/* Cards ocultos: coluna esq. encolhe, grid expande */
.page-lotes .form-lote-body.cards-config-ocultos .form-lote-col-esq {
    flex: 0 0 0;
    min-width: 0;
    overflow: hidden;
    padding: 0;
}
.page-lotes .form-lote-body.cards-config-ocultos .form-lote-col-dir {
    flex: 1;
    min-width: 0;
}
.page-lotes .section-modelos-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 8px;
}
.page-lotes .section-modelos-header h3 {
    margin: 0;
}
.page-lotes .section-modelos-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Campos compactos na tela de lotes */
.page-lotes .form-group {
    margin-bottom: 4px;
}

.page-lotes .grid-campos .form-group,
.page-lotes .grid-filtros .form-group {
    margin-bottom: 0;
}

.page-lotes .form-group-inline {
    margin-bottom: 0;
}

.page-lotes .form-group label {
    font-size: 11px;
    margin-bottom: 2px;
}

.page-lotes .form-control {
    padding: 4px 8px;
    font-size: 12px;
    max-width: 100%;
}

.page-lotes .form-control-sm {
    min-width: 0;
}

.page-lotes .form-control-lote {
    width: 70px;
}

.page-lotes .form-control-sm.form-control {
    padding: 4px 6px;
    font-size: 11px;
}

.page-lotes select.form-control-sm {
    min-width: 140px;
}

.page-lotes .form-buscar-row select.form-control-sm:first-of-type {
    min-width: 180px;
}

.page-lotes .checkbox-compact {
    margin-top: 2px !important;
}

.page-lotes .checkbox-item {
    font-size: 11px;
}

.page-lotes .section-card {
    margin-bottom: 0;
    padding: 6px 10px;
    flex-shrink: 0;
    width: 100%;
}

.page-lotes .section-card h3 {
    margin: 0 0 4px 0;
    font-size: 12px;
}

.page-lotes .section-execucao {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.page-lotes .section-execucao .form-row {
    margin-bottom: 4px;
}

.page-lotes .section-execucao .form-row:last-of-type {
    margin-bottom: 0;
}

.page-lotes .section-execucao .form-row-2 {
    grid-template-columns: 1fr auto;
}

.page-lotes .section-execucao .form-row-2 .checkbox-inline {
    align-self: center;
    margin-bottom: 0;
}

.page-lotes .checkbox-inline {
    display: flex;
    align-items: center;
    padding-bottom: 2px;
}

.page-lotes .grid-campos {
    display: grid;
    grid-template-columns: repeat(6, minmax(70px, 1fr));
    gap: 4px 8px;
}

.page-lotes .form-lote-col-esq .grid-campos {
    grid-template-columns: repeat(2, minmax(70px, 1fr));
}

.page-lotes .grid-filtros {
    grid-template-columns: repeat(5, minmax(70px, 1fr));
}

.page-lotes .form-lote-col-esq .grid-filtros {
    grid-template-columns: repeat(2, minmax(70px, 1fr));
}

@media (max-width: 1200px) {
    .page-lotes .form-lote-layout-30-70 { flex-direction: column; }
    .page-lotes .form-lote-col-esq { flex: 1 1 auto; }
    .page-lotes .grid-campos { grid-template-columns: repeat(4, minmax(70px, 1fr)); }
    .page-lotes .form-lote-col-esq .grid-campos { grid-template-columns: repeat(3, minmax(70px, 1fr)); }
    .page-lotes .grid-filtros { grid-template-columns: repeat(4, minmax(70px, 1fr)); }
    .page-lotes .form-lote-col-esq .grid-filtros { grid-template-columns: repeat(3, minmax(70px, 1fr)); }
}

@media (max-width: 900px) {
    .page-lotes .grid-campos { grid-template-columns: repeat(3, minmax(70px, 1fr)); }
    .page-lotes .form-lote-col-esq .grid-campos { grid-template-columns: repeat(2, minmax(70px, 1fr)); }
    .page-lotes .grid-filtros { grid-template-columns: repeat(3, minmax(70px, 1fr)); }
    .page-lotes .form-lote-col-esq .grid-filtros { grid-template-columns: repeat(2, minmax(70px, 1fr)); }
}

.page-lotes .mnemonicos-desc {
    font-size: 11px;
    color: var(--cinza-texto);
    margin: 0 0 6px 0;
}

.page-lotes .grid-mnemonicos {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 4px 8px;
    font-size: 11px;
}

.page-lotes .mnemonico-item {
    padding: 4px 8px;
    background: var(--cinza-claro);
    border-radius: 4px;
}

/* Popup de mnemônicos para Nome Arquivo */
.popup-mnemonico {
    position: fixed;
    z-index: 1000;
    background: var(--branco);
    border: 1px solid var(--cinza-medio);
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
    padding: 10px 12px;
    max-width: 420px;
    max-height: 70vh;
    overflow-y: auto;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.15s, visibility 0.15s;
}

.popup-mnemonico.popup-mnemonico-visible {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.popup-mnemonico-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
    font-weight: 600;
    font-size: 13px;
}

.popup-mnemonico-fechar {
    background: none;
    border: none;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    color: var(--cinza-texto);
    padding: 0 4px;
}

.popup-mnemonico-fechar:hover {
    color: var(--preto);
}

.popup-mnemonico-desc {
    font-size: 11px;
    color: var(--cinza-texto);
    margin: 0 0 8px 0;
}

.popup-mnemonico-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.popup-mnemonico-btn {
    padding: 4px 10px;
    font-size: 11px;
    background: var(--cinza-claro);
    border: 1px solid var(--cinza-medio);
    border-radius: 4px;
    cursor: pointer;
    font-family: monospace;
}

.popup-mnemonico-btn:hover {
    background: var(--azul-claro, #e3f2fd);
    border-color: var(--azul-principal, #1976d2);
}

.page-lotes .form-lote-body .section-card {
    margin-bottom: 0;
}

.page-lotes .section-opcoes,
.page-lotes .section-modelos {
    /* full width - default in flex */
}

.page-lotes .section-modelos {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    padding: 6px 10px;
}

.page-lotes .section-modelos h3 {
    margin-bottom: 4px;
}

.page-lotes .grid-modelos-wrap {
    flex: 1;
    min-height: 120px;
    overflow: auto;
    margin-top: 4px;
}

.page-lotes .grid-table th,
.page-lotes .grid-table td {
    padding: 2px 6px;
    font-size: 11px;
}

.page-lotes .grid-table input,
.page-lotes .grid-table select {
    padding: 3px 5px;
    font-size: 11px;
    min-width: 60px;
}

.page-lotes .grid-table select.select-com-desc {
    min-width: 80px;
}

.page-lotes .td-expand {
    vertical-align: middle;
    padding: 2px 4px;
}

.page-lotes .btn-expand {
    min-width: 28px;
    padding: 2px 6px;
    font-size: 10px;
}

.page-lotes .modelo-entrada-row .td-entrada {
    padding: 10px 12px;
    background: var(--cinza-claro, #f5f5f5);
    border-left: 3px solid var(--azul-principal, #1976d2);
    vertical-align: top;
}

.page-lotes .entrada-panel {
    max-width: 100%;
}

.page-lotes .entrada-title {
    margin: 0 0 8px 0;
    font-size: 12px;
    font-weight: 600;
}

.page-lotes .entrada-grid {
    width: 100%;
    margin-bottom: 8px;
    font-size: 11px;
}

.page-lotes .entrada-grid th {
    text-align: left;
    padding: 4px 8px;
    font-weight: 600;
}

.page-lotes .entrada-grid td {
    padding: 4px 8px;
}

.page-lotes .entrada-grid .form-control {
    min-width: 120px;
}

.page-lotes .entrada-grid .entrada-valor {
    min-width: 180px;
}

.page-lotes .input-with-btn {
    display: flex;
    gap: 4px;
    align-items: center;
}

.page-lotes .input-with-btn input {
    flex: 1;
    min-width: 0;
}

.page-lotes .btn-pesq-modelo {
    flex-shrink: 0;
    padding: 4px 8px;
}

.btn-modelo-item {
    display: block;
    width: 100%;
    text-align: left;
    padding: 8px 12px;
    margin-bottom: 4px;
    border: 1px solid var(--cinza-medio);
    border-radius: 4px;
    background: var(--branco);
    cursor: pointer;
    font-size: 13px;
}

.btn-modelo-item:hover {
    background: var(--cinza-claro, #f5f5f5);
    border-color: var(--azul-principal, #1976d2);
}

.modal-desc {
    font-size: 12px;
    color: var(--cinza-texto);
    margin: 0 0 12px 0;
}

.page-lotes .form-lote-actions {
    margin-top: 6px;
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.page-lotes .card-lotes-list {
    margin-top: 12px;
    padding: 12px 20px;
}

.page-lotes .card-lotes-list h3 {
    margin: 0 0 10px 0;
    font-size: 14px;
}
