/* =============================================
   GarantaFácil — Dark Theme
   ============================================= */

:root {
    --primary: #3b82f6;
    --primary-dark: #2563eb;
    --primary-light: rgba(59,130,246,.15);
    --success: #22c55e;
    --success-light: rgba(34,197,94,.12);
    --warning: #f59e0b;
    --warning-light: rgba(245,158,11,.12);
    --danger: #ef4444;
    --danger-light: rgba(239,68,68,.12);
    --info: #06b6d4;
    --info-light: rgba(6,182,212,.12);

    --bg-body: #0f1117;
    --bg-sidebar: #161822;
    --bg-card: #1a1d2e;
    --bg-card-hover: #1f2337;
    --bg-input: #12141f;
    --bg-topbar: #161822;

    --border: rgba(255,255,255,.06);
    --border-input: rgba(255,255,255,.1);
    --border-input-focus: var(--primary);

    --text: #e2e8f0;
    --text-muted: #94a3b8;
    --text-faint: #64748b;
    --text-heading: #f1f5f9;

    --card-alt: rgba(255,255,255,.04);

    --radius: 12px;
    --shadow: 0 2px 8px rgba(0,0,0,.3);
    --shadow-md: 0 4px 16px rgba(0,0,0,.4);
    --sidebar-w: 260px;
    --topbar-h: 56px;
    --bottomnav-h: 64px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-body);
    color: var(--text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* === SIDEBAR === */
.sidebar {
    position: fixed;
    left: -280px;
    top: 0;
    width: var(--sidebar-w);
    height: 100vh;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    transition: left .3s ease;
}
.sidebar.open { left: 0; }

.sidebar-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.6);
    z-index: 999; display: none;
}
.sidebar-overlay.show { display: block; }

.sidebar-header {
    padding: 20px;
    display: flex; align-items: center; justify-content: space-between;
    border-bottom: 1px solid var(--border);
}
.sidebar-header h2 { font-size: 18px; color: var(--primary); font-weight: 700; }
.sidebar-close {
    background: none; border: none;
    font-size: 20px; color: var(--text-muted);
    cursor: pointer;
}

.sidebar-nav { flex: 1; overflow-y: auto; padding: 12px 0; }
.sidebar-nav a {
    display: flex; align-items: center; gap: 12px;
    padding: 11px 20px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 14px;
    transition: all .15s;
    border-left: 3px solid transparent;
}
.sidebar-nav a:hover {
    background: rgba(255,255,255,.04);
    color: var(--text);
}
.sidebar-nav a.active {
    background: var(--primary-light);
    color: var(--primary);
    border-left-color: var(--primary);
}
.sidebar-nav a i { width: 20px; text-align: center; font-size: 15px; }
.sidebar-divider { height: 1px; background: var(--border); margin: 8px 16px; }

.badge-plano {
    margin-left: auto;
    background: var(--primary-light);
    color: var(--primary);
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
}
.sidebar-user {
    display: flex; align-items: center; gap: 8px;
    font-size: 13px; color: var(--text-muted);
    margin-bottom: 8px;
}
.btn-logout {
    display: flex; align-items: center; gap: 8px;
    color: var(--danger); text-decoration: none; font-size: 13px;
}

/* === TOPBAR === */
.topbar {
    display: flex; align-items: center;
    height: var(--topbar-h);
    padding: 0 16px;
    background: var(--bg-topbar);
    border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 50;
}
.btn-hamburger {
    background: none; border: none;
    font-size: 20px; color: var(--text-muted);
    cursor: pointer; padding: 8px;
}
.topbar-title {
    flex: 1; text-align: center;
    font-size: 16px; font-weight: 600;
    color: var(--text-heading);
}
.topbar-right { width: 36px; }

/* === MAIN === */
.main-content { min-height: 100vh; }
.page-content {
    padding: 16px;
    padding-bottom: calc(var(--bottomnav-h) + 24px + env(safe-area-inset-bottom, 0px));
    width: 100%;
}

/* === BOTTOM NAV === */
.bottom-nav {
    position: fixed; bottom: 0; left: 0; right: 0;
    height: var(--bottomnav-h);
    background: var(--bg-sidebar);
    border-top: 1px solid var(--border);
    display: flex; align-items: center;
    justify-content: space-around;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    z-index: 100;
}
.bottom-nav a {
    display: flex; flex-direction: column;
    align-items: center; gap: 2px;
    text-decoration: none;
    color: var(--text-faint);
    font-size: 10px;
    padding: 6px 12px;
    transition: color .15s;
}
.bottom-nav a i { font-size: 20px; }
.bottom-nav a.active { color: var(--primary); }
.bottom-nav .btn-fab {
    width: 48px; height: 48px;
    background: var(--primary); color: #fff;
    border-radius: 50%;
    display: flex; align-items: center;
    justify-content: center;
    font-size: 20px;
    box-shadow: 0 4px 16px rgba(59,130,246,.35);
    margin-top: -16px;
}

/* === STATS === */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 20px;
}
.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
}
.stat-card .stat-icon {
    width: 40px; height: 40px;
    border-radius: 10px;
    display: flex; align-items: center;
    justify-content: center;
    font-size: 18px;
    margin-bottom: 8px;
}
.stat-card .stat-value { font-size: 24px; font-weight: 700; color: var(--text-heading); }
.stat-card .stat-label { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

.stat-icon.green { background: var(--success-light); color: var(--success); }
.stat-icon.yellow { background: var(--warning-light); color: var(--warning); }
.stat-icon.red { background: var(--danger-light); color: var(--danger); }
.stat-icon.blue { background: var(--info-light); color: var(--info); }

/* === CARD === */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 16px;
    overflow: hidden;
}
.card-header {
    padding: 16px;
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center;
    justify-content: space-between;
}
.card-header h3 { font-size: 15px; font-weight: 600; color: var(--text-heading); }
.card-body { padding: 16px; }

/* === GARANTIA CARD === */
.garantia-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 12px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    cursor: pointer;
    transition: all .15s;
    text-decoration: none;
    color: inherit;
}
.garantia-card:hover {
    background: var(--bg-card-hover);
    border-color: rgba(255,255,255,.1);
}
.garantia-icon {
    width: 44px; height: 44px;
    border-radius: 10px;
    background: var(--primary-light);
    color: var(--primary);
    display: flex; align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}
.garantia-info { flex: 1; min-width: 0; }
.garantia-info h4 {
    font-size: 14px; font-weight: 600;
    color: var(--text-heading);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.garantia-meta { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.garantia-right { text-align: right; flex-shrink: 0; }
.garantia-dias { font-size: 20px; font-weight: 700; line-height: 1; }
.garantia-dias-label { font-size: 10px; color: var(--text-faint); }

.dias-green { color: var(--success); }
.dias-yellow { color: var(--warning); }
.dias-red { color: var(--danger); }

/* === BADGES === */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
}
.badge-success { background: var(--success-light); color: var(--success); }
.badge-warning { background: var(--warning-light); color: var(--warning); }
.badge-danger { background: var(--danger-light); color: var(--danger); }
.badge-info { background: var(--info-light); color: var(--info); }

/* === FORMS === */
.form-group { margin-bottom: 16px; }
.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 6px;
}
.form-control {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--border-input);
    border-radius: 8px;
    font-size: 15px;
    color: var(--text);
    background: var(--bg-input);
    transition: border-color .15s;
    -webkit-appearance: none;
}
.form-control:focus {
    outline: none;
    border-color: var(--border-input-focus);
    box-shadow: 0 0 0 3px rgba(59,130,246,.15);
}
.form-control::placeholder { color: var(--text-faint); }
select.form-control { padding-right: 36px; color: var(--text); }
select.form-control option { background: var(--bg-card); color: var(--text); }
textarea.form-control { resize: vertical; min-height: 80px; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-hint { font-size: 12px; color: var(--text-faint); margin-top: 4px; }

/* === BUTTONS === */
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    border: none; border-radius: 8px;
    font-size: 14px; font-weight: 600;
    cursor: pointer;
    transition: all .15s;
    text-decoration: none;
    white-space: nowrap;
}
.btn-block { width: 100%; }
.btn-primary {
    background: var(--primary); color: #fff;
    box-shadow: 0 2px 8px rgba(59,130,246,.25);
}
.btn-primary:hover { background: var(--primary-dark); transform: translateY(-1px); }
.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-outline {
    background: transparent;
    border: 1px solid var(--border-input);
    color: var(--text-muted);
}
.btn-outline:hover { background: rgba(255,255,255,.04); color: var(--text); }
.btn-sm { padding: 8px 14px; font-size: 12px; }
.btn-group { display: flex; gap: 8px; }

/* === FLASH === */
.flash {
    padding: 14px 16px;
    border-radius: var(--radius);
    margin: 0 0 16px;
    font-size: 14px;
    animation: flashIn .3s ease;
    border: 1px solid;
}
.flash-sucesso { background: var(--success-light); color: var(--success); border-color: rgba(34,197,94,.2); }
.flash-erro { background: var(--danger-light); color: var(--danger); border-color: rgba(239,68,68,.2); }
.flash-aviso { background: var(--warning-light); color: var(--warning); border-color: rgba(245,158,11,.2); }
.flash-info { background: var(--info-light); color: var(--info); border-color: rgba(6,182,212,.2); }

@keyframes flashIn {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* === UPLOAD === */
.upload-area {
    border: 2px dashed rgba(255,255,255,.12);
    border-radius: var(--radius);
    padding: 32px 16px;
    text-align: center;
    cursor: pointer;
    transition: all .15s;
    position: relative;
    overflow: hidden;
    background: rgba(255,255,255,.02);
}
.upload-area:hover,
.upload-area.dragover {
    border-color: var(--primary);
    background: var(--primary-light);
}
.upload-area input[type="file"] {
    position: absolute; inset: 0; opacity: 0; cursor: pointer;
}
.upload-area i { font-size: 32px; color: var(--text-faint); margin-bottom: 8px; }
.upload-area p { font-size: 14px; color: var(--text-muted); }
.upload-area .upload-hint { font-size: 12px; color: var(--text-faint); margin-top: 4px; }

.upload-preview { display: none; margin-top: 12px; }
.upload-preview img {
    max-width: 100%; max-height: 200px;
    border-radius: 8px; object-fit: contain;
}

/* === LOADING === */
.loading-overlay {
    position: fixed; inset: 0;
    background: rgba(15,17,23,.92);
    z-index: 9999; display: none;
    flex-direction: column;
    align-items: center; justify-content: center;
    gap: 16px;
}
.loading-overlay.show { display: flex; }
.spinner {
    width: 40px; height: 40px;
    border: 3px solid rgba(255,255,255,.1);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text { font-size: 14px; color: var(--text-muted); }

/* === TABLE === */
.table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.table { width: 100%; border-collapse: collapse; font-size: 13px; }
table.table th {
    padding: 10px 12px;
    background: rgba(255,255,255,.03);
    color: var(--text-faint);
    text-align: left; font-weight: 600;
    font-size: 11px; text-transform: uppercase;
    letter-spacing: .5px;
}
table.table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    color: var(--text);
}

/* === FILTROS === */
.filtros {
    display: flex; gap: 8px;
    overflow-x: auto;
    padding-bottom: 4px;
    margin-bottom: 16px;
    -webkit-overflow-scrolling: touch;
}
.filtro-btn {
    padding: 8px 16px;
    border: 1px solid var(--border-input);
    border-radius: 20px;
    background: transparent;
    font-size: 13px;
    color: var(--text-muted);
    white-space: nowrap;
    cursor: pointer;
    transition: all .15s;
}
.filtro-btn.active,
.filtro-btn:hover {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

/* === EMPTY STATE === */
.empty-state {
    text-align: center; padding: 48px 20px;
}
.empty-state i { font-size: 48px; color: var(--text-faint); margin-bottom: 16px; }
.empty-state h3 { font-size: 16px; color: var(--text-muted); margin-bottom: 8px; }
.empty-state p { font-size: 13px; color: var(--text-faint); margin-bottom: 20px; }

/* === AUTH PAGES === */
.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: var(--bg-body);
}
.auth-card {
    width: 100%;
    max-width: 400px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 32px 24px;
}
.auth-card h1 {
    font-size: 22px;
    text-align: center;
    margin-bottom: 24px;
    color: var(--text-heading);
}
.auth-card .logo {
    text-align: center;
    font-size: 28px;
    font-weight: 800;
    color: var(--primary);
    margin-bottom: 8px;
}
.auth-footer {
    text-align: center;
    margin-top: 16px;
    font-size: 13px;
    color: var(--text-faint);
}
.auth-footer a { color: var(--primary); text-decoration: none; }

.btn-google {
    width: 100%; padding: 12px;
    border: 1px solid var(--border-input);
    border-radius: 8px;
    background: transparent;
    display: flex; align-items: center;
    justify-content: center; gap: 10px;
    font-size: 14px; cursor: pointer;
    margin-bottom: 16px;
    color: var(--text);
    text-decoration: none;
    transition: background .15s;
}
.btn-google:hover { background: rgba(255,255,255,.04); }

.divider {
    display: flex; align-items: center;
    gap: 12px; margin: 16px 0;
    font-size: 12px; color: var(--text-faint);
}
.divider::before, .divider::after {
    content: ''; flex: 1;
    height: 1px; background: var(--border);
}

/* === DESKTOP === */
@media (min-width: 769px) {
    .sidebar {
        left: 0;
        border-right: 1px solid var(--border);
    }
    .sidebar-close { display: none; }
    .sidebar-overlay { display: none !important; }
    .btn-hamburger { display: none; }

    .main-content { margin-left: var(--sidebar-w); }
    .topbar { padding-left: 24px; }
    .topbar-title { text-align: left; }

    .bottom-nav { display: none; }
    .page-content {
        padding: 24px;
        padding-bottom: 24px;
        width: 100%;
    }

    .stats-grid { grid-template-columns: repeat(4, 1fr); }
}
