@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
    --primary: #003366;
    --accent: #007bff;
    --danger: #d9534f;
    --warning: #f0ad4e;
    --success: #28a745;
    --bg: #f4f7fa;
    --sidebar-w: 260px;
}

* { box-sizing: border-box; }
body { margin: 0; font-family: 'Inter', sans-serif; background: var(--bg); display: flex; }

/* LAYOUT */
.login-page { justify-content: center; align-items: center; min-height: 100vh; background: linear-gradient(135deg, #cce0ff 0%, #ffffff 100%); padding: 15px; }
.login-container { background: white; padding: 40px 20px; border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,0.1); width: 100%; max-width: 400px; text-align: center; display: flex; flex-direction: column; }
.logo-login { width: 200px; margin: 0 auto 20px; }
.login-container input { padding: 12px; margin-bottom: 15px; border: 1px solid #ddd; border-radius: 6px; font-size: 16px; }
.login-container button { padding: 12px; background: var(--primary); color: white; border: none; border-radius: 6px; cursor: pointer; font-weight: 600; font-size: 16px; }

.sidebar { width: var(--sidebar-w); background: var(--primary); color: white; height: 100vh; position: fixed; left: 0; top: 0; display: flex; flex-direction: column; padding: 20px; z-index: 100; overflow-y: auto; }
.sidebar-logo { text-align: center; padding-bottom: 30px; border-bottom: 1px solid rgba(255,255,255,0.1); }
.nav-links { list-style: none; padding: 20px 0; margin: 0; flex-grow: 1; }
.nav-links li { padding: 15px; cursor: pointer; border-radius: 8px; margin-bottom: 5px; display: flex; align-items: center; gap: 12px; color: #cbd5e0; font-size: 13px; }
.nav-links li:hover, .nav-links li.active { background: rgba(255,255,255,0.1); color: white; }
.sidebar-user { border-top: 1px solid rgba(255,255,255,0.1); padding-top: 20px; text-align: center; font-size: 13px; }
.sidebar-user button { width: 100%; padding: 10px; background: var(--danger); color: white; border: none; border-radius: 6px; cursor: pointer; margin-top: 10px; font-size: 12px; }

.main-content { margin-left: var(--sidebar-w); width: calc(100% - var(--sidebar-w)); padding: 40px; overflow-x: hidden; }
.main-header { margin-bottom: 25px; border-bottom: 2px solid var(--primary); padding-bottom: 10px; }
.main-header h1 { font-size: 28px; margin: 0; }
.card { background: white; padding: 25px; border-radius: 10px; box-shadow: 0 4px 6px rgba(0,0,0,0.05); margin-bottom: 25px; }

/* COMPONENTES */
.grid-inputs { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 15px; }
.grid-inputs input, .scanner-section input, #searchItem { padding: 12px; border: 1px solid #cfd9e6; border-radius: 6px; width: 100%; font-size: 14px; }
.date-container { position: relative; }
.date-container label { position: absolute; left: 10px; top: -8px; background: white; padding: 0 4px; font-size: 11px; color: var(--primary); }
.btn-add { background: var(--success); color: white; margin-top: 15px; padding: 12px 25px; border: none; border-radius: 6px; cursor: pointer; font-weight: 600; font-size: 14px; }
.btn-primary { background: var(--accent); color: white; padding: 10px 18px; border: none; border-radius: 6px; cursor: pointer; font-weight: 600; font-size: 13px; }
.btn-danger-sm { background: var(--danger); color: white; border: none; margin-top: 6px; padding: 5px 10px; border-radius: 4px; cursor: pointer; font-size: 11px; width: 100%; }

/* TABELA */
.table-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; margin-top: 10px; font-size: 13px; }
th, td { padding: 12px; text-align: left; border-bottom: 1px solid #edf2f7; font-size: 13px; }
th { background: #f8fafc; color: var(--primary); font-weight: 700; }
.celula-dado { display: block; border-bottom: 1px dashed #eee; padding: 6px 0; min-height: 32px; display: flex; align-items: center; }
.celula-dado:last-child { border-bottom: none; }
.row-expired { background-color: #fff5f5; color: var(--danger); }
.row-warning { background-color: #fffaf0; color: #856404; }
.text-danger { color: var(--danger); font-weight: bold; }

/* BANNERS */
.banner { padding: 15px; border-radius: 8px; margin-bottom: 10px; font-weight: bold; border-left: 5px solid; font-size: 13px; }
.banner-warning { background: #fff3cd; color: #856404; border-color: #ffeeba; }
.banner-danger { background: #f8d7da; color: #721c24; border-color: #f5c6cb; }

/* MODAL E DRAG & DROP */
.modal-overlay { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.6); z-index: 1000; justify-content: center; align-items: center; overflow-y: auto; padding: 15px; }
.modal-card { background: white; width: 95%; max-width: 1300px; padding: 30px; border-radius: 12px; max-height: 95vh; display: flex; flex-direction: column; margin: auto; }
.modal-header { display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid #eee; padding-bottom: 10px; margin-bottom: 15px; gap: 15px; }
.modal-header h2 { margin: 0; font-size: 18px; }
.btn-close { font-size: 24px; border: none; background: none; cursor: pointer; flex-shrink: 0; }
.modal-grid-layout { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; overflow-y: auto; }

.drop-zone { border: 2px dashed var(--accent); border-radius: 8px; padding: 25px; text-align: center; color: var(--primary); cursor: pointer; background: #f8fafc; transition: all 0.3s ease; }
.drop-zone:hover, .drop-zone.dragover { background: #e2e8f0; border-color: var(--primary); }

/* MODAL DE SEGURANÇA (LIMPEZA DE HISTÓRICO) */
#modalConfirmarLimpeza {
    backdrop-filter: blur(4px);
}

#modalConfirmarLimpeza .modal-card {
    max-width: 450px;
    border-top: 5px solid var(--danger);
}

#modalConfirmarLimpeza .modal-body p {
    color: #4a5568;
    line-height: 1.5;
    margin-bottom: 20px;
    font-size: 14px;
}

.auth-input-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.auth-input-group input {
    width: 100%;
    padding: 14px;
    border: 1px solid #cfd9e6;
    border-radius: 8px;
    font-size: 15px;
    transition: border-color 0.2s;
}

.auth-input-group input:focus {
    border-color: var(--primary);
    outline: none;
    box-shadow: 0 0 0 3px rgba(0, 51, 102, 0.1);
}

.btn-confirm-delete {
    background: var(--danger);
    color: white;
    border: none;
    padding: 15px;
    border-radius: 8px;
    font-weight: 700;
    cursor: pointer;
    margin-top: 10px;
    transition: filter 0.2s;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-confirm-delete:hover {
    filter: brightness(0.9);
}

@keyframes popIn {
    from { transform: scale(0.95); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

#modalConfirmarLimpeza .modal-card {
    animation: popIn 0.2s ease-out;
}

#modal-camera .modal-card {
    max-width: 500px;
}

#leitor-qr {
    background: #000;
    border-radius: 8px;
    overflow: hidden;
    border: 2px solid var(--primary);
}

#leitor-qr video {
    object-fit: cover !important;
}

/* Classes para as tarjas de vencimento na tabela */
.tarja-vencido {
    background-color: rgba(220, 53, 69, 0.15);
    border-left: 4px solid #dc3545;
    display: block; 
    padding: 2px 6px;
    margin-bottom: 2px;
    border-radius: 2px;
}

.tarja-vencendo {
    background-color: rgba(255, 193, 7, 0.15);
    border-left: 4px solid #ffc107;
    display: block;
    padding: 2px 6px;
    margin-bottom: 2px;
    border-radius: 2px;
}

/* ========== ESTILOS PARA AUDITORIA ========== */
.auditoria-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 0;
}

.auditoria-table thead th {
    background: #f8fafc;
    padding: 14px;
    text-align: center;
    font-weight: 700;
    color: var(--primary);
    border-bottom: 2px solid #e2e8f0;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.auditoria-table tbody tr {
    border-bottom: 1px solid #e2e8f0;
    transition: background-color 0.2s ease;
}

.auditoria-table tbody tr:hover {
    background-color: #fafbfc;
}

.auditoria-table td {
    padding: 14px;
    font-size: 13px;
    text-align: center;
}

.auditoria-table td:first-child,
.auditoria-table td:nth-child(2) {
    text-align: left;
}

.auditoria-input {
    width: 100%;
    padding: 10px;
    border: 2px solid #e2e8f0;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    text-align: center;
    transition: all 0.2s ease;
}

.auditoria-input:focus {
    outline: none;
    border-color: var(--accent);
    background: #f0f7ff;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}

.auditoria-status {
    padding: 6px 12px;
    border-radius: 6px;
    font-weight: 600;
    font-size: 12px;
    white-space: nowrap;
}

.status-igual {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.status-maior {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffeeba;
}

.status-menor {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.diferenca-display {
    font-weight: 700;
    padding: 8px;
    border-radius: 4px;
    min-width: 50px;
}

.diferenca-positiva {
    color: var(--success);
    background: rgba(40, 167, 69, 0.1);
}

.diferenca-negativa {
    color: var(--danger);
    background: rgba(217, 83, 79, 0.1);
}

.diferenca-neutra {
    color: #6c757d;
    background: rgba(108, 117, 125, 0.1);
}

/* ========== RESPONSIVE DESIGN ========== */

/* TABLET (768px) */
@media (max-width: 1024px) {
    :root {
        --sidebar-w: 220px;
    }

    .main-content {
        padding: 25px;
    }

    .card {
        padding: 20px;
    }

    .grid-inputs {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    }

    .modal-grid-layout {
        grid-template-columns: 1fr;
    }

    .modal-card {
        padding: 20px;
    }

    th, td {
        padding: 10px;
        font-size: 12px;
    }

    .nav-links li {
        padding: 12px;
        font-size: 12px;
    }
}

/* MOBILE (480px - 768px) */
@media (max-width: 768px) {
    :root {
        --sidebar-w: 0;
    }

    body {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        height: auto;
        position: static;
        padding: 12px;
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        background: var(--primary);
        box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    }

    .sidebar-logo {
        padding-bottom: 0;
        border-bottom: none;
        display: none;
    }

    .sidebar-logo svg {
        width: 80px !important;
    }

    .nav-links {
        display: flex;
        flex-direction: row;
        padding: 0;
        margin: 0;
        gap: 3px;
        flex-wrap: nowrap;
        flex-grow: 0;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        width: calc(100% - 80px);
    }

    .nav-links li {
        padding: 10px 8px;
        margin-bottom: 0;
        font-size: 11px;
        white-space: nowrap;
        flex-shrink: 0;
        gap: 4px;
        border-radius: 6px;
        transition: background 0.2s;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .nav-links li:active {
        background: rgba(255,255,255,0.2);
    }

    .nav-links li i {
        font-size: 13px;
    }

    .sidebar-user {
        border-top: none;
        padding-top: 0;
        border-left: 1px solid rgba(255,255,255,0.2);
        padding-left: 8px;
        margin-left: 0;
        text-align: center;
        display: flex;
        align-items: center;
        gap: 8px;
    }

    .sidebar-user p {
        display: none;
    }

    .sidebar-user button {
        width: auto;
        padding: 8px 10px;
        margin-top: 0;
        font-size: 11px;
        white-space: nowrap;
    }

    .main-content {
        margin-left: 0;
        width: 100%;
        padding: 12px;
    }

    .main-header {
        margin-bottom: 15px;
        border-bottom: 2px solid var(--primary);
        padding-bottom: 8px;
    }

    .main-header h1 {
        font-size: 22px;
        margin: 0;
    }

    .card {
        padding: 15px;
        margin-bottom: 15px;
        border-radius: 8px;
    }

    .card h3 {
        font-size: 16px;
        margin: 10px 0 15px 0;
    }

    .grid-inputs {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .grid-inputs input {
        padding: 12px;
        font-size: 16px;
        border-radius: 6px;
        border: 1.5px solid #cfd9e6;
    }

    .grid-inputs input:focus {
        border-color: var(--accent);
        background: #f0f7ff;
    }

    .scanner-section {
        padding: 15px !important;
    }

    .scanner-section > div {
        flex-direction: column !important;
        gap: 12px !important;
    }

    .scanner-section label {
        font-size: 12px !important;
        font-weight: 600 !important;
    }

    .scanner-section input {
        font-size: 16px;
        padding: 12px;
    }

    #btn-abrir-camera {
        width: 50px !important;
        height: 50px !important;
        padding: 0 !important;
        margin-top: 0 !important;
    }

    .modal-overlay {
        padding: 0;
        align-items: flex-end;
    }

    .modal-card {
        max-width: 100%;
        padding: 15px;
        max-height: 90vh;
        border-radius: 12px 12px 0 0;
        margin: 0;
        width: 100%;
    }

    .modal-header {
        flex-wrap: wrap;
        gap: 10px;
        margin-bottom: 12px;
    }

    .modal-header h2 {
        font-size: 18px;
        flex: 1;
        margin: 0;
    }

    .btn-close {
        font-size: 28px;
        padding: 0;
        width: 32px;
        height: 32px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .modal-grid-layout {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    .drop-zone {
        padding: 20px;
        border-radius: 8px;
    }

    .drop-zone p {
        font-size: 13px;
        margin: 5px 0;
    }

    .drop-zone i {
        font-size: 1.8em;
    }

    th, td {
        padding: 10px 8px;
        font-size: 12px;
    }

    th {
        font-size: 11px;
        font-weight: 700;
    }

    table {
        font-size: 12px;
    }

    .btn-add {
        margin-top: 12px;
        padding: 12px 16px;
        font-size: 14px;
        width: 100%;
        border-radius: 6px;
        font-weight: 600;
        min-height: 44px;
    }

    .btn-primary {
        padding: 10px 14px;
        font-size: 13px;
        min-height: 40px;
    }

    .btn-danger-sm {
        padding: 6px 10px;
        font-size: 11px;
        min-height: 36px;
    }

    .form-actions {
        display: flex;
        flex-direction: column;
        gap: 10px;
    }

    .form-actions button {
        width: 100%;
    }

    .table-wrapper {
        border-radius: 8px;
        border: 1px solid #edf2f7;
        box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    }

    .auditoria-table td,
    .auditoria-table th {
        padding: 12px 8px;
        font-size: 12px;
    }

    .auditoria-table thead th {
        font-size: 11px;
        padding: 10px 6px;
    }

    .auditoria-input {
        padding: 10px;
        font-size: 14px;
        min-height: 40px;
    }

    .login-container {
        padding: 25px 15px;
        max-width: 95%;
    }

    .login-container input,
    .login-container button {
        font-size: 16px;
        padding: 12px;
        min-height: 44px;
        border-radius: 6px;
    }

    .logo-login {
        width: 180px;
        margin-bottom: 20px;
    }

    .modal-body {
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .banner {
        font-size: 13px;
        padding: 12px;
        border-radius: 6px;
        margin-bottom: 10px;
    }

    .auditoria-info {
        padding: 12px !important;
        font-size: 13px !important;
        border-radius: 6px !important;
    }

    div[style*="display: flex"] {
        flex-direction: column;
    }

    div[style*="display: flex; gap"] {
        gap: 10px;
    }

    .auditoria-status {
        padding: 6px 10px;
        border-radius: 4px;
        font-weight: 600;
        font-size: 11px;
        white-space: normal;
    }

    .diferenca-display {
        font-weight: 700;
        padding: 6px;
        border-radius: 4px;
        min-width: 45px;
        font-size: 12px;
    }

    .table-previsao {
        font-size: 12px;
    }

    .table-previsao th {
        font-size: 11px;
        padding: 8px;
    }

    .table-previsao td {
        font-size: 12px;
        padding: 8px;
    }

    .auth-input-group {
        gap: 10px;
    }

    .auth-input-group input {
        font-size: 16px;
        padding: 12px;
        min-height: 44px;
    }

    .btn-confirm-delete {
        font-size: 14px;
        padding: 12px;
        min-height: 44px;
    }

    #searchItem {
        font-size: 16px;
        padding: 12px;
        min-height: 44px;
    }

    .modal-card p {
        font-size: 14px;
        line-height: 1.5;
    }
}

/* TELEFONE PEQUENO (até 480px) */
@media (max-width: 480px) {
    .main-content {
        padding: 10px;
    }

    .card {
        padding: 12px;
        margin-bottom: 12px;
        border-radius: 6px;
    }

    .card h3 {
        font-size: 15px;
        margin: 8px 0 12px 0;
    }

    .grid-inputs {
        gap: 8px;
    }

    .grid-inputs input {
        font-size: 16px;
        padding: 10px;
    }

    .modal-card {
        padding: 12px;
        margin: 0;
        border-radius: 12px 12px 0 0;
    }

    .modal-header h2 {
        font-size: 16px;
    }

    .btn-close {
        font-size: 24px;
        width: 28px;
        height: 28px;
    }

    th, td {
        padding: 8px;
        font-size: 11px;
    }

    th {
        font-size: 10px;
        font-weight: 700;
    }

    .btn-add, .btn-primary {
        padding: 10px 12px;
        font-size: 13px;
        min-height: 40px;
    }

    .btn-danger-sm {
        padding: 6px 8px;
        font-size: 10px;
        min-height: 32px;
    }

    .nav-links li {
        padding: 8px 6px;
        font-size: 10px;
    }

    .sidebar-user button {
        font-size: 10px;
        padding: 6px 8px;
    }

    .login-container {
        padding: 20px 12px;
    }

    .login-container input,
    .login-container button {
        font-size: 16px;
        padding: 10px;
        min-height: 40px;
    }

    .logo-login {
        width: 150px;
        margin-bottom: 15px;
    }

    .scanner-section label {
        font-size: 11px !important;
    }

    .scanner-section input {
        font-size: 16px;
    }

    #btn-abrir-camera {
        width: 44px !important;
        height: 44px !important;
    }

    .main-header h1 {
        font-size: 18px;
    }

    .auditoria-input {
        font-size: 13px;
        padding: 8px;
        min-height: 36px;
    }

    .auditoria-status {
        font-size: 10px;
        padding: 4px 6px;
    }

    .diferenca-display {
        font-size: 11px;
        padding: 4px;
    }

    #searchItem {
        font-size: 16px;
        padding: 10px;
        min-height: 40px;
    }

    .banner {
        font-size: 12px;
        padding: 10px;
    }

    .auditoria-info {
        padding: 10px !important;
        font-size: 12px !important;
    }

    .modal-body p {
        font-size: 13px;
    }

    .table-previsao th {
        font-size: 10px;
        padding: 6px;
    }

    .table-previsao td {
        font-size: 11px;
        padding: 6px;
    }

    .auth-input-group input {
        font-size: 16px;
        padding: 10px;
    }

    .btn-confirm-delete {
        font-size: 13px;
        padding: 10px;
    }
}