/* ============================================================
   Admin CSS — Sistema de Documentos Mensais
   Alves & Fonseca Transportes
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* ── Reset & Base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --sidebar-w: 260px;
    --color-bg:        #F0F4F8;
    --color-sidebar:   #1A2332;
    --color-sidebar-hover: #243348;
    --color-sidebar-active: #2E4A6B;
    --color-accent:    #3B82F6;
    --color-accent-h:  #2563EB;
    --color-success:   #22C55E;
    --color-warning:   #F59E0B;
    --color-danger:    #EF4444;
    --color-text:      #1E293B;
    --color-muted:     #64748B;
    --color-border:    #E2E8F0;
    --color-surface:   #FFFFFF;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,.08);
    --shadow-md: 0 4px 16px rgba(0,0,0,.1);
    --shadow-lg: 0 8px 32px rgba(0,0,0,.12);
    --transition: 0.18s ease;
}

html, body {
    height: 100%;
    font-family: 'Inter', system-ui, sans-serif;
    font-size: 15px;
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.6;
}

a { color: var(--color-accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Layout ──────────────────────────────────────────────── */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* ── Sidebar ─────────────────────────────────────────────── */
.sidebar {
    width: var(--sidebar-w);
    background: var(--color-sidebar);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    position: fixed;
    top: 0; left: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 100;
    box-shadow: 2px 0 12px rgba(0,0,0,.15);
}

.sidebar-brand {
    padding: 1.75rem 1.5rem 1.25rem;
    border-bottom: 1px solid rgba(255,255,255,.08);
}

.sidebar-brand .logo-icon {
    width: 38px;
    height: 38px;
    background: var(--color-accent);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: .75rem;
}

.sidebar-brand .logo-icon svg { width: 22px; height: 22px; fill: white; }

.sidebar-brand h1 {
    font-size: .875rem;
    font-weight: 700;
    color: white;
    line-height: 1.3;
}

.sidebar-brand p {
    font-size: .7rem;
    color: rgba(255,255,255,.45);
    margin-top: .2rem;
    font-weight: 400;
}

.sidebar-nav {
    padding: 1rem 0;
    flex: 1;
}

.nav-label {
    font-size: .65rem;
    font-weight: 600;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: rgba(255,255,255,.3);
    padding: .75rem 1.5rem .4rem;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .625rem 1.5rem;
    color: rgba(255,255,255,.7);
    font-size: .875rem;
    font-weight: 500;
    transition: background var(--transition), color var(--transition);
    cursor: pointer;
    text-decoration: none;
}

.nav-item:hover {
    background: var(--color-sidebar-hover);
    color: white;
    text-decoration: none;
}

.nav-item.active {
    background: var(--color-sidebar-active);
    color: white;
}

.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; opacity: .75; }
.nav-item:hover svg, .nav-item.active svg { opacity: 1; }

/* Subitems — leve recuo e separador esquerdo */
.nav-subitem {
    padding-left: 2rem;
    font-size: .825rem;
    border-left: 2px solid transparent;
    margin-left: .5rem;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.nav-subitem:hover {
    border-left-color: rgba(255,255,255,.25);
}

.nav-subitem.active {
    border-left-color: var(--color-accent);
}

.sidebar-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid rgba(255,255,255,.08);
}

.sidebar-footer form button {
    width: 100%;
    padding: .5rem;
    background: rgba(255,255,255,.07);
    border: 1px solid rgba(255,255,255,.1);
    color: rgba(255,255,255,.7);
    border-radius: var(--radius-sm);
    font-size: .8rem;
    font-family: inherit;
    cursor: pointer;
    transition: background var(--transition);
}

.sidebar-footer form button:hover {
    background: rgba(255,255,255,.14);
    color: white;
}

/* ── Main Content ─────────────────────────────────────────── */
.main-content {
    margin-left: var(--sidebar-w);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.topbar {
    background: var(--color-surface);
    padding: 1rem 2rem;
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow-sm);
}

.topbar-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--color-text);
}

.topbar-sub {
    font-size: .8rem;
    color: var(--color-muted);
    margin-top: .1rem;
}

.page-body {
    padding: 2rem;
    flex: 1;
}

/* ── Alerts (flash) ──────────────────────────────────────── */
.alert {
    padding: .875rem 1.25rem;
    border-radius: var(--radius-md);
    font-size: .875rem;
    font-weight: 500;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: .625rem;
}

.alert svg { width: 18px; height: 18px; flex-shrink: 0; }

.alert-success {
    background: #DCFCE7;
    color: #166534;
    border: 1px solid #BBF7D0;
}

.alert-error {
    background: #FEE2E2;
    color: #991B1B;
    border: 1px solid #FECACA;
}

/* ── Cards ───────────────────────────────────────────────── */
.card {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--color-border);
}

.card-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.card-title {
    font-size: .9375rem;
    font-weight: 600;
    color: var(--color-text);
}

.card-body { padding: 1.5rem; }

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    padding: .5rem 1rem;
    border-radius: var(--radius-sm);
    font-size: .875rem;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    border: 1px solid transparent;
    transition: background var(--transition), transform var(--transition), box-shadow var(--transition);
    text-decoration: none;
    white-space: nowrap;
    line-height: 1.4;
}

.btn:hover { text-decoration: none; transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.btn:active { transform: translateY(0); }

.btn svg { width: 15px; height: 15px; }

.btn-primary {
    background: var(--color-accent);
    color: white;
    border-color: var(--color-accent);
}
.btn-primary:hover { background: var(--color-accent-h); border-color: var(--color-accent-h); }

.btn-success {
    background: var(--color-success);
    color: white;
}
.btn-success:hover { background: #16A34A; }

.btn-danger {
    background: var(--color-danger);
    color: white;
}
.btn-danger:hover { background: #DC2626; }

.btn-outline {
    background: transparent;
    color: var(--color-text);
    border-color: var(--color-border);
}
.btn-outline:hover { background: var(--color-bg); }

.btn-ghost {
    background: transparent;
    color: var(--color-muted);
    border: none;
}
.btn-ghost:hover { color: var(--color-danger); background: #FEF2F2; }

.btn-sm {
    padding: .3rem .7rem;
    font-size: .8rem;
}

.btn-sm svg { width: 13px; height: 13px; }

.btn-copy {
    background: #F1F5F9;
    color: var(--color-text);
    border: 1px solid var(--color-border);
    font-size: .8rem;
}
.btn-copy:hover { background: #E2E8F0; }
.btn-copy.copied { background: #DCFCE7; color: #166534; border-color: #BBF7D0; }

/* ── Badges / Status ─────────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    padding: .2rem .65rem;
    border-radius: 999px;
    font-size: .75rem;
    font-weight: 600;
}

.badge-andamento {
    background: #FEF3C7;
    color: #92400E;
}

.badge-completo {
    background: #D1FAE5;
    color: #065F46;
}

.badge-count {
    background: var(--color-bg);
    color: var(--color-muted);
    border: 1px solid var(--color-border);
}

/* ── Dashboard Grid ──────────────────────────────────────── */
.months-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.25rem;
    margin-top: 1.5rem;
}

.month-card {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--color-border);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    transition: box-shadow var(--transition), transform var(--transition);
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.month-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.month-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: .5rem;
}

.month-card-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--color-text);
}

.month-card-meta {
    font-size: .78rem;
    color: var(--color-muted);
    margin-top: .15rem;
}

.month-card-actions {
    display: flex;
    gap: .5rem;
    flex-wrap: wrap;
}

.month-link-row {
    display: flex;
    align-items: center;
    gap: .5rem;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: .4rem .75rem;
    font-size: .75rem;
    color: var(--color-muted);
    word-break: break-all;
    flex: 1;
    min-width: 0;
}

.month-link-row span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}

/* ── Empty State ─────────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--color-muted);
}

.empty-state svg {
    width: 56px;
    height: 56px;
    color: #CBD5E1;
    margin-bottom: 1rem;
}

.empty-state h3 { font-size: 1rem; color: var(--color-text); margin-bottom: .5rem; }
.empty-state p { font-size: .875rem; margin-bottom: 1.5rem; }

/* ── Form ─────────────────────────────────────────────────── */
.form-group { margin-bottom: 1.25rem; }

.form-label {
    display: block;
    font-size: .875rem;
    font-weight: 500;
    color: var(--color-text);
    margin-bottom: .5rem;
}

.form-control {
    width: 100%;
    padding: .625rem .875rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: .9rem;
    color: var(--color-text);
    background: var(--color-surface);
    transition: border-color var(--transition), box-shadow var(--transition);
    appearance: none;
}

.form-control:focus {
    outline: none;
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px rgba(59,130,246,.15);
}

.form-select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%2394A3B8'%3E%3Cpath fill-rule='evenodd' d='M5.23 7.21a.75.75 0 011.06.02L10 11.168l3.71-3.938a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right .75rem center;
    background-size: 1rem;
    padding-right: 2.5rem;
}

.form-hint {
    font-size: .78rem;
    color: var(--color-muted);
    margin-top: .375rem;
}

/* ── Document Slots ──────────────────────────────────────── */
.section-title {
    font-size: .9rem;
    font-weight: 600;
    color: var(--color-muted);
    text-transform: uppercase;
    letter-spacing: .06em;
    margin-bottom: 1rem;
    margin-top: 1.75rem;
    padding-bottom: .5rem;
    border-bottom: 2px solid var(--color-border);
    display: flex;
    align-items: center;
    gap: .5rem;
}

.section-title svg { width: 16px; height: 16px; }

.doc-slot {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    margin-bottom: .75rem;
    overflow: hidden;
    transition: border-color var(--transition);
}

.doc-slot:hover { border-color: #94A3B8; }

.doc-slot-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.25rem;
}

.doc-slot-status {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.doc-slot-status.filled {
    background: #DCFCE7;
}

.doc-slot-status.pending {
    background: #FEF3C7;
}

.doc-slot-status svg { width: 15px; height: 15px; }

.doc-slot-name {
    flex: 1;
    font-size: .875rem;
    font-weight: 500;
    color: var(--color-text);
}

.doc-slot-actions {
    display: flex;
    align-items: center;
    gap: .5rem;
}

.doc-slot-files {
    border-top: 1px solid var(--color-border);
    background: #FAFBFC;
}

.doc-file-row {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .6rem 1.25rem;
    border-bottom: 1px solid var(--color-border);
    font-size: .8rem;
}

.doc-file-row:last-child { border-bottom: none; }

.doc-file-icon { flex-shrink: 0; color: var(--color-muted); }
.doc-file-icon svg { width: 15px; height: 15px; }

.doc-file-name {
    flex: 1;
    color: var(--color-text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.doc-file-meta { color: var(--color-muted); white-space: nowrap; }

/* ── Upload inline form ───────────────────────────────────── */
.upload-form-inline {
    padding: .75rem 1.25rem;
    background: #F8FAFC;
    border-top: 1px dashed var(--color-border);
    display: none;
}

.upload-form-inline.open { display: block; }

.upload-drop-area {
    border: 2px dashed var(--color-border);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    text-align: center;
    cursor: pointer;
    transition: border-color var(--transition), background var(--transition);
}

.upload-drop-area:hover, .upload-drop-area.drag-over {
    border-color: var(--color-accent);
    background: #EFF6FF;
}

.upload-drop-area input[type="file"] { display: none; }

.upload-drop-area p {
    font-size: .8rem;
    color: var(--color-muted);
    margin-top: .5rem;
}

.upload-drop-area svg { width: 28px; height: 28px; color: #94A3B8; }

.upload-file-list {
    margin-top: .75rem;
    font-size: .8rem;
    color: var(--color-text);
}

.upload-file-list li {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .25rem 0;
    color: var(--color-muted);
}

.upload-actions {
    display: flex;
    gap: .5rem;
    margin-top: .75rem;
    justify-content: flex-end;
}

/* ── Outros documentos ────────────────────────────────────── */
.outros-section {
    background: var(--color-surface);
    border: 1px dashed #CBD5E1;
    border-radius: var(--radius-md);
    padding: 1.25rem;
    margin-top: 1rem;
}

/* ── Login page ──────────────────────────────────────────── */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1A2332 0%, #2E4A6B 100%);
    padding: 1.5rem;
}

.login-card {
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 2.5rem;
    width: 100%;
    max-width: 400px;
}

.login-logo {
    text-align: center;
    margin-bottom: 2rem;
}

.login-logo .icon {
    width: 52px;
    height: 52px;
    background: var(--color-accent);
    border-radius: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1rem;
}

.login-logo .icon svg { width: 28px; height: 28px; fill: white; }

.login-logo h1 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--color-text);
    line-height: 1.3;
}

.login-logo p {
    font-size: .8rem;
    color: var(--color-muted);
    margin-top: .25rem;
}

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 768px) {
    .sidebar { display: none; }
    .main-content { margin-left: 0; }
    .months-grid { grid-template-columns: 1fr; }
    .page-body { padding: 1rem; }
    .topbar { padding: .875rem 1rem; }
}

/* ── Animations ──────────────────────────────────────────── */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.fade-in { animation: fadeIn .25s ease; }

/* ── Confirm modal ───────────────────────────────────────── */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition);
}

.modal-backdrop.open {
    opacity: 1;
    pointer-events: all;
}

.modal {
    background: white;
    border-radius: var(--radius-lg);
    padding: 2rem;
    max-width: 400px;
    width: 90%;
    box-shadow: var(--shadow-lg);
    transform: scale(.95);
    transition: transform var(--transition);
}

.modal-backdrop.open .modal { transform: scale(1); }

.modal h3 { font-size: 1rem; font-weight: 600; margin-bottom: .5rem; }
.modal p { font-size: .875rem; color: var(--color-muted); margin-bottom: 1.5rem; }
.modal-actions { display: flex; gap: .75rem; justify-content: flex-end; }
