/* ==========================================================================
   GESTOR CLIENTES PRO - DESIGN SYSTEM & RESPONSIVE CSS
   Suporte Completo a Mobile (iOS/Android), Tablets, Laptops e Desktops
   ========================================================================== */

:root {
    --bg-primary: #03070d;
    --bg-secondary: #07111d;
    --bg-card: #0b2238;
    --border-card: rgba(74, 185, 239, 0.2);
    --border-light: rgba(255, 255, 255, 0.08);
    --text-primary: #eef7ff;
    --text-muted: #91adc1;
    --accent-cyan: #42c9ff;
    --accent-blue: #0c73aa;
    --accent-teal: #16bfae;
    --accent-red: #d24c5c;
    --accent-yellow: #e6a219;
    --sidebar-w: 260px;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --transition: all 0.22s ease;
}

*, *::before, *::after {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    margin: 0;
    padding: 0;
    min-height: 100vh;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background: radial-gradient(circle at 15% 10%, #123a61 0%, #07111d 42%, #03070d 100%) fixed;
    color: var(--text-primary);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

a {
    text-decoration: none;
    color: inherit;
}

/* ==========================================================================
   ESTRUTURA GERAL (LAYOUT)
   ========================================================================== */

.layout {
    display: flex;
    min-height: 100vh;
    position: relative;
}

/* SIDEBAR DESKTOP */
.sidebar {
    width: var(--sidebar-w);
    background: linear-gradient(180deg, #0b2741 0%, #06121f 100%);
    border-right: 1px solid rgba(44, 131, 187, 0.35);
    padding: 20px 14px;
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 100;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    display: flex;
    flex-direction: column;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.3);
}

.sidebar::-webkit-scrollbar {
    width: 4px;
}
.sidebar::-webkit-scrollbar-thumb {
    background: rgba(66, 201, 255, 0.2);
    border-radius: 4px;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    padding: 6px 8px 12px;
    border-bottom: 1px solid rgba(74, 185, 239, 0.15);
}

.brand {
    font-weight: 900;
    font-size: 19px;
    letter-spacing: 0.5px;
    color: #fff;
    user-select: none;
}
.brand span {
    color: var(--accent-cyan);
}

.sidebar-close-btn {
    display: none;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #fff;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: var(--transition);
}
.sidebar-close-btn:hover {
    background: rgba(210, 76, 92, 0.3);
    border-color: var(--accent-red);
}

.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(3, 7, 13, 0.75);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    z-index: 99;
    opacity: 0;
    transition: opacity 0.25s ease;
}
.sidebar-backdrop.active {
    display: block;
    opacity: 1;
}

/* NAVEGAÇÃO DA SIDEBAR */
.nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
}

.nav a {
    display: flex;
    gap: 12px;
    align-items: center;
    padding: 11px 13px;
    border-radius: var(--radius-md);
    color: #b9d4e8;
    font-size: 14px;
    font-weight: 500;
    transition: var(--transition);
    border: 1px solid transparent;
}

.nav a:hover {
    background: rgba(13, 95, 145, 0.28);
    color: #fff;
    border-color: rgba(66, 201, 255, 0.2);
}

.nav a.active {
    background: linear-gradient(135deg, #0d5f91 0%, #12324f 100%);
    color: #fff;
    font-weight: 700;
    border-color: rgba(66, 201, 255, 0.35);
    box-shadow: 0 4px 16px rgba(27, 166, 223, 0.25);
}

.nav a.nav-logout {
    margin-top: auto;
    color: #ff9a9a;
    border-color: rgba(210, 76, 92, 0.2);
    background: rgba(210, 76, 92, 0.08);
}
.nav a.nav-logout:hover {
    background: rgba(210, 76, 92, 0.25);
    color: #fff;
}

/* CONTEÚDO PRINCIPAL (MAIN) */
.main {
    margin-left: var(--sidebar-w);
    width: calc(100% - var(--sidebar-w));
    padding: 26px 30px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* BARRA SUPERIOR (HEADER / TOP) */
.top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 22px;
    gap: 14px;
    flex-wrap: wrap;
}

.top-left {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
}

.mobile-menu {
    display: none;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    padding: 0;
    border-radius: var(--radius-md);
    background: linear-gradient(135deg, #0f3554, #19517e);
    border: 1px solid rgba(74, 185, 239, 0.3);
    color: #fff;
    font-size: 20px;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3);
    transition: var(--transition);
    flex-shrink: 0;
}
.mobile-menu:hover {
    background: linear-gradient(135deg, #13466f, #226da8);
    border-color: var(--accent-cyan);
}

.top-heading h1 {
    margin: 0;
    font-size: 25px;
    font-weight: 800;
    line-height: 1.2;
    color: #fff;
}
.top-subtitle {
    font-size: 13px;
    margin-top: 3px;
    color: var(--text-muted);
}

.user-badge {
    background: rgba(13, 40, 66, 0.7);
    border: 1px solid rgba(74, 185, 239, 0.25);
    border-radius: 30px;
    padding: 6px 14px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 600;
    color: #d8eeff;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}
.user-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent-teal);
    box-shadow: 0 0 8px var(--accent-teal);
}

/* ==========================================================================
   CARDS & GRIDS RESPONSIVOS
   ========================================================================== */

.grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 16px;
}

.card {
    background: linear-gradient(145deg, #102d46dd, #071522f2);
    border: 1px solid var(--border-card);
    border-radius: var(--radius-lg);
    padding: 19px;
    box-shadow: 0 10px 35px rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    transition: transform 0.2s ease, border-color 0.2s ease;
}

.card:hover {
    border-color: rgba(74, 185, 239, 0.35);
}

/* CARDS DE ESTATÍSTICA (KPI) */
.stat {
    display: flex;
    flex-direction: column;
}
.stat .icon {
    font-size: 26px;
    line-height: 1;
}
.stat .label {
    color: #9bb6c9;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    margin-top: 10px;
}
.stat .value {
    font-size: 28px;
    font-weight: 900;
    margin-top: 4px;
    color: #fff;
    line-height: 1.1;
    word-break: break-all;
}

.section {
    margin-top: 18px;
}

.section-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
    gap: 12px;
    flex-wrap: wrap;
}
.section-title h2, .section-title h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
    color: #eaf7ff;
}

/* ==========================================================================
   BOTÕES E AÇÕES TOUCH-FRIENDLY
   ========================================================================== */

.btn {
    border: 0;
    border-radius: var(--radius-md);
    padding: 10px 16px;
    min-height: 40px;
    background: linear-gradient(135deg, #0c73aa 0%, #42c9ff 100%);
    color: #fff;
    font-weight: 700;
    font-size: 13px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    text-align: center;
    user-select: none;
    transition: var(--transition);
    box-shadow: 0 4px 14px rgba(12, 115, 170, 0.3);
    white-space: nowrap;
}

.btn:hover {
    filter: brightness(1.12);
    box-shadow: 0 6px 20px rgba(66, 201, 255, 0.4);
}
.btn:active {
    transform: scale(0.98);
}

.btn.secondary {
    background: linear-gradient(135deg, #15334d, #1c4568);
    border: 1px solid rgba(74, 185, 239, 0.2);
    box-shadow: none;
}
.btn.secondary:hover {
    background: linear-gradient(135deg, #1c4568, #255783);
    border-color: var(--accent-cyan);
}
.btn.secondary.active {
    background: linear-gradient(135deg, #0d5f91, #167cb8);
    border-color: var(--accent-cyan);
    color: #fff;
    box-shadow: 0 0 14px rgba(66, 201, 255, 0.35);
}

.btn.danger {
    background: linear-gradient(135deg, #8d1d2a 0%, #d24c5c 100%);
    box-shadow: 0 4px 14px rgba(210, 76, 92, 0.3);
}
.btn.danger:hover {
    box-shadow: 0 6px 20px rgba(210, 76, 92, 0.45);
}

.btn.warning {
    background: linear-gradient(135deg, #8d560c 0%, #e6a219 100%);
    box-shadow: 0 4px 14px rgba(230, 162, 25, 0.3);
}

.btn.success {
    background: linear-gradient(135deg, #096a64 0%, #16bfae 100%);
    box-shadow: 0 4px 14px rgba(22, 191, 174, 0.3);
}

.actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}

/* ==========================================================================
   CAMPOS DE FORMULÁRIO (INPUTS, SELECTS, TEXTAREAS)
   ========================================================================== */

input, select, textarea {
    width: 100%;
    background: #081725;
    border: 1px solid #2c6c91;
    color: #eaf7ff;
    border-radius: var(--radius-md);
    padding: 11px 13px;
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: var(--transition);
}

input:focus, select:focus, textarea:focus {
    border-color: var(--accent-cyan);
    box-shadow: 0 0 12px rgba(66, 201, 255, 0.3);
    background: #0b1f33;
}

label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #9eb8c9;
    margin: 0 0 6px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
}

.full {
    grid-column: 1 / -1;
}

/* BARRA DE PESQUISA */
.search {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
    align-items: center;
}
.search input {
    flex: 1;
}
.search .btn {
    flex-shrink: 0;
}

/* ==========================================================================
   TABELAS E ROLAGEM TOUCH RESPONSIVA
   ========================================================================== */

.table-wrap {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius-md);
    position: relative;
    margin-top: 10px;
}

.table-wrap::-webkit-scrollbar {
    height: 6px;
}
.table-wrap::-webkit-scrollbar-track {
    background: #061524;
    border-radius: 4px;
}
.table-wrap::-webkit-scrollbar-thumb {
    background: #25668d;
    border-radius: 4px;
}
.table-wrap::-webkit-scrollbar-thumb:hover {
    background: var(--accent-cyan);
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 650px;
}

th, td {
    padding: 13px 10px;
    border-bottom: 1px solid var(--border-light);
    text-align: left;
    vertical-align: middle;
}

th {
    color: #86b7d3;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: rgba(8, 23, 37, 0.4);
}

td {
    font-size: 14px;
    color: #eaf7ff;
}

code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    background: rgba(0, 0, 0, 0.35);
    padding: 3px 6px;
    border-radius: 6px;
    font-size: 13px;
    color: #92e0ff;
    border: 1px solid rgba(74, 185, 239, 0.15);
}

/* BADGES DE STATUS */
.badge {
    padding: 6px 11px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.3px;
    display: inline-flex;
    align-items: center;
    white-space: nowrap;
}

.badge.normal {
    background: #0e604c;
    color: #6ef5d2;
    border: 1px solid rgba(110, 245, 210, 0.3);
}
.badge.warning {
    background: #70560d;
    color: #ffd873;
    border: 1px solid rgba(255, 216, 115, 0.3);
}
.badge.soon, .badge.today {
    background: #9a4d0d;
    color: #ffb873;
    border: 1px solid rgba(255, 184, 115, 0.3);
}
.badge.expired {
    background: #8c1f2a;
    color: #ff9a9a;
    border: 1px solid rgba(255, 154, 154, 0.3);
}

.blink {
    animation: blink 1.2s infinite;
}
@keyframes blink {
    50% {
        box-shadow: 0 0 0 4px rgba(255, 90, 90, 0.2), 0 0 16px rgba(255, 90, 90, 0.6);
    }
}

.alert {
    border: 1px solid rgba(255, 140, 74, 0.4);
    background: rgba(60, 27, 12, 0.6);
    border-radius: var(--radius-md);
    padding: 14px 16px;
}

/* ==========================================================================
   TELA DE LOGIN
   ========================================================================== */

.login {
    display: grid;
    place-items: center;
    min-height: 100vh;
    padding: 18px;
}

.login-box {
    width: min(430px, 100%);
    padding: clamp(22px, 5vw, 34px);
    border-radius: 20px;
}

.logo {
    font-size: clamp(24px, 5vw, 30px);
    font-weight: 900;
    text-align: center;
    margin-bottom: 6px;
    color: #fff;
}
.logo span {
    color: var(--accent-cyan);
}

.login-box .btn {
    width: 100%;
    margin-top: 10px;
    min-height: 44px;
}

.error {
    color: #ff9a9a;
    background: rgba(80, 25, 35, 0.8);
    border: 1px solid rgba(255, 90, 90, 0.3);
    padding: 11px 14px;
    border-radius: var(--radius-md);
    margin-bottom: 14px;
    font-size: 13px;
    font-weight: 600;
}

.muted {
    color: var(--text-muted);
}

/* ==========================================================================
   MEDIA QUERIES PARA RESPONSIVIDADE COMPLETA
   ========================================================================== */

/* 1. Laptops e Tablets Grandes (<= 1100px) */
@media (max-width: 1100px) {
    .grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* 2. Tablets Médios e Telas Verticais (<= 992px) */
@media (max-width: 992px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);
        width: 280px;
        max-width: 85vw;
        box-shadow: 10px 0 40px rgba(0, 0, 0, 0.7);
        z-index: 1000;
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .sidebar-close-btn {
        display: flex;
    }
    
    .main {
        margin-left: 0;
        width: 100%;
        padding: 18px 16px;
    }
    
    .mobile-menu {
        display: inline-flex;
    }
    
    .top-heading h1 {
        font-size: 22px;
    }
}

/* 3. Smartphones / Mobile (<= 768px) */
@media (max-width: 768px) {
    /* Regra vital: Impede que o iOS dê zoom automático ao focar em inputs */
    input, select, textarea {
        font-size: 16px !important;
    }
    
    .main {
        padding: 14px 12px;
    }
    
    .top {
        margin-bottom: 16px;
    }
    
    .top-heading h1 {
        font-size: 20px;
    }
    
    .top-subtitle {
        font-size: 12px;
    }
    
    .card {
        padding: 15px 13px;
        border-radius: var(--radius-md);
    }
    
    /* 2 colunas para KPIs no mobile com visual compacto tipo app nativo */
    .grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
    
    .stat {
        padding: 12px 10px;
    }
    
    .stat .icon {
        font-size: 22px;
    }
    
    .stat .label {
        font-size: 11px;
        margin-top: 6px;
    }
    
    .stat .value {
        font-size: 22px;
    }
    
    .form-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    .full {
        grid-column: auto;
    }
    
    .section-title {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    
    .section-title .actions {
        width: 100%;
        display: flex;
        flex-wrap: wrap;
        gap: 6px;
    }
    
    .section-title .actions .btn {
        flex: 1 1 auto;
        min-height: 38px;
        padding: 8px 12px;
        font-size: 12px;
    }
    
    th, td {
        padding: 10px 8px;
        font-size: 13px;
    }
    
    .btn {
        min-height: 42px;
        font-size: 13px;
    }
}

/* 4. Telas Ultra-Compactas / Smartphones Pequenos (<= 380px) */
@media (max-width: 380px) {
    .grid {
        grid-template-columns: 1fr;
    }
    
    .top-heading h1 {
        font-size: 18px;
    }
    
    .user-badge {
        display: none; /* Oculta badge na barra de topo para não espremer título */
    }
    
    .search {
        flex-direction: column;
    }
    
    .search .btn {
        width: 100%;
    }
}

/* Modais Responsivos */
@media (max-width: 600px) {
    .modal-cliente-grid {
        grid-template-columns: 1fr !important;
        gap: 8px !important;
    }
    #modal-lembrete-overlay > div {
        padding: 16px 12px !important;
        width: 95vw !important;
    }
}

