/* ============================================================
   EPI CONTROL — ESTILOS PRINCIPAIS
   Stack: Bootstrap 5.3 + CSS Custom
   ============================================================ */

:root {
    --sidebar-width: 260px;
    --sidebar-bg: #0f172a;
    --sidebar-hover: #1e293b;
    --sidebar-active: #1d4ed8;
    --sidebar-text: #94a3b8;
    --sidebar-text-active: #ffffff;
    --topbar-height: 60px;
    --primary: #1d4ed8;
    --primary-dark: #1e40af;
    --surface: #f8fafc;
    --border: #e2e8f0;
    --text-muted: #64748b;
    --radius: 10px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--surface);
    color: #1e293b;
}

/* ── Sidebar ─────────────────────────────────────────────── */
.sidebar {
    position: fixed;
    top: 0; left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    z-index: 1000;
    transition: transform .25s ease;
    overflow-y: auto;
}

.sidebar-brand {
    padding: 20px 20px 16px;
    font-size: 1.25rem;
    font-weight: 700;
    color: #fff;
    letter-spacing: .5px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid rgba(255,255,255,.08);
}

.sidebar-nav {
    flex: 1;
    padding: 12px 10px;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 9px 12px;
    border-radius: 8px;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: .9rem;
    transition: all .15s;
    margin-bottom: 2px;
}

.sidebar-link:hover {
    background: var(--sidebar-hover);
    color: #fff;
}

.sidebar-link.active {
    background: var(--sidebar-active);
    color: var(--sidebar-text-active);
    font-weight: 600;
}

.sidebar-link i { width: 18px; text-align: center; font-size: .95rem; }

.sidebar-divider {
    font-size: .7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #475569;
    padding: 12px 12px 4px;
    margin-top: 4px;
}

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

.sidebar-user-name { font-size: .85rem; font-weight: 600; color: #e2e8f0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-role { font-size: .75rem; color: var(--sidebar-text); }

.avatar-sm {
    width: 34px; height: 34px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: .85rem;
    flex-shrink: 0;
}

/* ── Main Wrapper ────────────────────────────────────────── */
.main-wrapper {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin-left .25s ease;
}

.main-wrapper.sidebar-collapsed { margin-left: 0; }

/* ── Topbar ──────────────────────────────────────────────── */
.topbar {
    height: var(--topbar-height);
    background: #fff;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0; z-index: 999;
}

.topbar-left { display: flex; align-items: center; gap: 16px; }
.sidebar-toggle { color: #475569; padding: 4px 8px; border: none; }
.breadcrumb { font-size: .85rem; }
.breadcrumb-item a { color: var(--primary); text-decoration: none; }

/* ── Page Content ────────────────────────────────────────── */
.page-content { flex: 1; padding: 28px 28px 40px; }

/* ── Página Header ───────────────────────────────────────── */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    gap: 12px;
    flex-wrap: wrap;
}

.page-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: #0f172a;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* ── Cards ───────────────────────────────────────────────── */
.card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 1px 3px rgba(0,0,0,.06);
}

.card-header {
    background: #fff;
    border-bottom: 1px solid var(--border);
    padding: 14px 20px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    border-radius: var(--radius) var(--radius) 0 0 !important;
}

/* ── Stat Cards (Dashboard) ──────────────────────────────── */
.stat-card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,.06);
    transition: box-shadow .2s;
}

.stat-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,.1); }

.stat-icon {
    width: 52px; height: 52px;
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.3rem;
    flex-shrink: 0;
}

.stat-icon.blue   { background: #dbeafe; color: #1d4ed8; }
.stat-icon.green  { background: #dcfce7; color: #16a34a; }
.stat-icon.orange { background: #fff7ed; color: #ea580c; }
.stat-icon.red    { background: #fee2e2; color: #dc2626; }
.stat-icon.purple { background: #ede9fe; color: #7c3aed; }

.stat-value { font-size: 1.8rem; font-weight: 700; color: #0f172a; line-height: 1; }
.stat-label { font-size: .82rem; color: var(--text-muted); margin-top: 2px; }

/* ── Table ───────────────────────────────────────────────── */
.table-container {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.table { margin: 0; font-size: .88rem; }
.table thead th {
    background: #f8fafc;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    font-size: .8rem;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: #475569;
    padding: 12px 16px;
}
.table tbody td { padding: 12px 16px; vertical-align: middle; border-color: #f1f5f9; }
.table tbody tr:hover { background: #f8fafc; }

/* ── Forms ───────────────────────────────────────────────── */
.form-label { font-weight: 600; font-size: .85rem; color: #374151; margin-bottom: 4px; }
.form-control, .form-select {
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: .9rem;
    padding: 8px 12px;
    transition: border-color .15s, box-shadow .15s;
}
.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(29,78,216,.12);
}

.form-section {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 20px;
}

.form-section-title {
    font-size: .85rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--text-muted);
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

/* ── Buttons ─────────────────────────────────────────────── */
.btn { border-radius: 8px; font-weight: 500; font-size: .88rem; }
.btn-primary { background: var(--primary); border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }

/* ── Badges ──────────────────────────────────────────────── */
.badge { font-weight: 500; font-size: .78rem; padding: .35em .65em; border-radius: 6px; }

/* ── Alertas dropdown ────────────────────────────────────── */
.alertas-dropdown {
    min-width: 340px;
    max-height: 400px;
    overflow-y: auto;
}
.alerta-item {
    font-size: .83rem;
    white-space: normal;
    padding: 8px 16px;
    border-left: 3px solid transparent;
}
.alerta-warning { border-left-color: #f59e0b; }
.alerta-danger  { border-left-color: #ef4444; }
.alerta-info    { border-left-color: #3b82f6; }

/* ── Login page ──────────────────────────────────────────── */
.login-wrapper {
    min-height: 100vh;
    background: linear-gradient(135deg, #0f172a 0%, #1e3a8a 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.login-card {
    background: #fff;
    border-radius: 16px;
    padding: 40px 36px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 20px 60px rgba(0,0,0,.3);
}

.login-logo {
    text-align: center;
    margin-bottom: 28px;
}

.login-logo i { font-size: 3rem; color: var(--primary); }
.login-logo h1 { font-size: 1.5rem; font-weight: 700; margin-top: 8px; }
.login-logo p  { color: var(--text-muted); font-size: .9rem; }

/* ── Signature page ──────────────────────────────────────── */
.signature-wrapper {
    min-height: 100vh;
    background: #f0f4ff;
    padding: 20px;
}

.signature-card {
    max-width: 680px;
    margin: 0 auto;
    background: #fff;
    border-radius: 16px;
    padding: 32px;
    box-shadow: 0 4px 24px rgba(0,0,0,.1);
}

#signatureCanvas {
    border: 2px dashed #cbd5e1;
    border-radius: 8px;
    background: #f8fafc;
    cursor: crosshair;
    touch-action: none;
    width: 100%;
    display: block;
}

#signatureCanvas.has-signature {
    border-color: #22c55e;
    border-style: solid;
}

.canvas-controls { display: flex; gap: 8px; margin-top: 8px; }

/* ── Estoque status ──────────────────────────────────────── */
.estoque-ok     { color: #16a34a; }
.estoque-baixo  { color: #ea580c; }
.estoque-zerado { color: #dc2626; }

/* ── Paginação ───────────────────────────────────────────── */
.pagination .page-link { color: var(--primary); border-radius: 6px; margin: 0 2px; }
.pagination .page-item.active .page-link { background: var(--primary); border-color: var(--primary); }

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .main-wrapper {
        margin-left: 0;
    }
    .page-content { padding: 16px; }
    .topbar { padding: 0 16px; }
    .stat-value { font-size: 1.4rem; }
}

/* ── Utilities ───────────────────────────────────────────── */
.text-truncate-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.action-btns { display: flex; gap: 4px; flex-wrap: wrap; }
.action-btns .btn { padding: 4px 8px; font-size: .78rem; }

/* Print (PDF) */
@media print {
    .sidebar, .topbar, .no-print { display: none !important; }
    .main-wrapper { margin: 0 !important; }
    .page-content { padding: 0 !important; }
}
