/* ============================================================
   SISTEMA ERP - PRINTTECH ANGOLA
   Estilos principais
   ============================================================ */

:root {
    /* Paleta principal */
    --primary: #0f172a;
    --primary-light: #1e293b;
    --accent: #f97316;
    --accent-hover: #ea580c;
    --accent-light: #fed7aa;

    /* Cores funcionais */
    --bg: #f8fafc;
    --surface: #ffffff;
    --surface-2: #f1f5f9;
    --border: #e2e8f0;
    --border-strong: #cbd5e1;

    /* Texto */
    --text: #0f172a;
    --text-muted: #64748b;
    --text-light: #94a3b8;

    /* Estados */
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #3b82f6;
    --purple: #8b5cf6;

    /* Sidebar */
    --sidebar-bg: #0f172a;
    --sidebar-text: #cbd5e1;
    --sidebar-active: #f97316;
    --sidebar-hover: rgba(255,255,255,0.06);

    /* Sombras */
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
    --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.05), 0 2px 4px rgba(0,0,0,0.04);
    --shadow-lg: 0 10px 15px rgba(0,0,0,0.08), 0 4px 6px rgba(0,0,0,0.05);
    --shadow-xl: 0 20px 25px rgba(0,0,0,0.1), 0 10px 10px rgba(0,0,0,0.04);

    /* Layout */
    --sidebar-width: 260px;
    --topbar-height: 76px;
    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 14px;
    --radius-xl: 20px;
}

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

html, body {
    font-family: 'Plus Jakarta Sans', -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, textarea, select { font-family: inherit; font-size: inherit; }

/* ============= LAYOUT ============= */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* ============= SIDEBAR ============= */
.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.sidebar-header {
    padding: 24px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--accent), #fb923c);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 20px;
    color: white;
    box-shadow: 0 4px 12px rgba(249,115,22,0.4);
}

.logo-text {
    font-weight: 700;
    color: white;
    font-size: 15px;
    letter-spacing: -0.01em;
}

.logo-sub {
    font-size: 11px;
    color: var(--text-light);
    margin-top: 2px;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    overflow-y: auto;
}

.nav-section {
    font-size: 10px;
    font-weight: 700;
    color: var(--text-light);
    letter-spacing: 0.08em;
    margin: 20px 12px 8px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    color: var(--sidebar-text);
    font-size: 13.5px;
    font-weight: 500;
    margin-bottom: 2px;
    transition: all 0.15s;
    position: relative;
}

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

.nav-item.active {
    background: rgba(249,115,22,0.12);
    color: var(--accent);
}

.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 60%;
    background: var(--accent);
    border-radius: 0 3px 3px 0;
}

.nav-item svg { flex-shrink: 0; }

.nav-badge {
    margin-left: auto;
    background: rgba(255,255,255,0.1);
    color: white;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 7px;
    border-radius: 10px;
}

.nav-badge-red { background: var(--danger); }

.sidebar-user {
    padding: 16px;
    border-top: 1px solid rgba(255,255,255,0.08);
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 13px;
    flex-shrink: 0;
}

.user-info { flex: 1; min-width: 0; }
.user-name {
    color: white;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.user-role {
    font-size: 11px;
    color: var(--text-light);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.btn-logout {
    color: var(--text-light);
    padding: 6px;
    border-radius: 6px;
    transition: all 0.15s;
    display: flex;
}
.btn-logout:hover { background: rgba(255,255,255,0.08); color: var(--danger); }

/* ============= MAIN CONTENT ============= */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.topbar {
    height: var(--topbar-height);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 10;
}

.page-title {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.page-subtitle {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 2px;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.search-box {
    position: relative;
    width: 280px;
}

.search-box svg {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-light);
}

.search-box input {
    width: 100%;
    padding: 9px 12px 9px 36px;
    background: var(--surface-2);
    border: 1px solid transparent;
    border-radius: var(--radius);
    font-size: 13px;
    transition: all 0.15s;
}
.search-box input:focus {
    outline: none;
    background: white;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(249,115,22,0.1);
}

.topbar-btn {
    width: 38px;
    height: 38px;
    border-radius: var(--radius);
    background: var(--surface-2);
    color: var(--text);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: all 0.15s;
}
.topbar-btn:hover { background: var(--border); }

.topbar-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    background: var(--danger);
    color: white;
    font-size: 10px;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    padding: 0 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--surface);
}

.page-content {
    padding: 32px;
    flex: 1;
}

/* ============= CARDS ============= */
.card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.card-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-title {
    font-size: 15px;
    font-weight: 700;
}

.card-body { padding: 24px; }

/* ============= STATS GRID ============= */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0;
    width: 4px;
    height: 100%;
    background: var(--accent);
}

.stat-card.green::before { background: var(--success); }
.stat-card.blue::before { background: var(--info); }
.stat-card.purple::before { background: var(--purple); }
.stat-card.red::before { background: var(--danger); }
.stat-card.amber::before { background: var(--warning); }

.stat-label {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 10px;
}

.stat-value {
    font-size: 28px;
    font-weight: 800;
    letter-spacing: -0.02em;
    margin-bottom: 4px;
}

.stat-trend {
    font-size: 12px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 4px;
}

.stat-trend.up { color: var(--success); }
.stat-trend.down { color: var(--danger); }

.stat-icon {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: rgba(249,115,22,0.1);
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
}

.stat-card.green .stat-icon { background: rgba(16,185,129,0.1); color: var(--success); }
.stat-card.blue .stat-icon { background: rgba(59,130,246,0.1); color: var(--info); }
.stat-card.purple .stat-icon { background: rgba(139,92,246,0.1); color: var(--purple); }
.stat-card.red .stat-icon { background: rgba(239,68,68,0.1); color: var(--danger); }
.stat-card.amber .stat-icon { background: rgba(245,158,11,0.1); color: var(--warning); }

/* ============= BADGES ============= */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.01em;
}

.badge-azul { background: #dbeafe; color: #1e40af; }
.badge-verde { background: #d1fae5; color: #065f46; }
.badge-amarelo { background: #fef3c7; color: #92400e; }
.badge-laranja { background: #ffedd5; color: #9a3412; }
.badge-vermelho { background: #fee2e2; color: #991b1b; }
.badge-roxo { background: #ede9fe; color: #5b21b6; }
.badge-cinza { background: #e2e8f0; color: #334155; }

/* ============= BOTÕES ============= */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 600;
    transition: all 0.15s;
    border: 1px solid transparent;
    cursor: pointer;
    white-space: nowrap;
}

.btn-primary {
    background: var(--primary);
    color: white;
}
.btn-primary:hover { background: var(--primary-light); }

.btn-accent {
    background: var(--accent);
    color: white;
    box-shadow: 0 2px 6px rgba(249,115,22,0.25);
}
.btn-accent:hover { background: var(--accent-hover); }

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

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
}
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }

.btn-success { background: var(--success); color: white; }
.btn-danger { background: var(--danger); color: white; }
.btn-sm { padding: 6px 12px; font-size: 12px; }

/* ============= FORMS ============= */
.form-group { margin-bottom: 18px; }

.form-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 6px;
    letter-spacing: 0.01em;
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    font-size: 13.5px;
    transition: all 0.15s;
}

.form-control:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(249,115,22,0.1);
}

textarea.form-control { resize: vertical; min-height: 90px; }

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.form-help {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* ============= TABELAS ============= */
.table-wrapper {
    overflow-x: auto;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    background: var(--surface);
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th {
    text-align: left;
    padding: 12px 18px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.table td {
    padding: 14px 18px;
    font-size: 13px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: var(--surface-2); }

.table-actions {
    display: flex;
    gap: 6px;
}

/* ============= LOGIN PAGE ============= */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background:
        radial-gradient(circle at 20% 30%, rgba(249,115,22,0.15), transparent 40%),
        radial-gradient(circle at 80% 70%, rgba(99,102,241,0.15), transparent 40%),
        var(--primary);
    padding: 20px;
    position: relative;
    overflow: hidden;
}

.login-page::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(255,255,255,0.02) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,0.02) 1px, transparent 1px);
    background-size: 32px 32px;
    pointer-events: none;
}

.login-container {
    background: var(--surface);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    width: 100%;
    max-width: 460px;
    padding: 40px;
    position: relative;
    z-index: 1;
}

.login-logo {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 32px;
}

.login-logo .logo-icon {
    width: 52px;
    height: 52px;
    font-size: 26px;
}

.login-logo h1 {
    font-size: 22px;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.login-logo p {
    font-size: 12px;
    color: var(--text-muted);
}

.login-tabs {
    display: flex;
    gap: 4px;
    background: var(--surface-2);
    padding: 4px;
    border-radius: var(--radius);
    margin-bottom: 28px;
}

.login-tab {
    flex: 1;
    padding: 10px;
    border-radius: 8px;
    text-align: center;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s;
}

.login-tab.active {
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow-sm);
}

.login-title {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 6px;
}

.login-subtitle {
    color: var(--text-muted);
    font-size: 13px;
    margin-bottom: 24px;
}

.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    font-size: 13px;
    margin-bottom: 16px;
    border: 1px solid;
}

.alert-error {
    background: #fef2f2;
    border-color: #fecaca;
    color: #991b1b;
}

.alert-success {
    background: #f0fdf4;
    border-color: #bbf7d0;
    color: #166534;
}

.alert-info {
    background: #eff6ff;
    border-color: #bfdbfe;
    color: #1e40af;
}

.login-footer {
    text-align: center;
    margin-top: 20px;
    font-size: 12px;
    color: var(--text-muted);
}

.login-footer a { color: var(--accent); font-weight: 600; }

.demo-creds {
    background: var(--surface-2);
    border-radius: var(--radius);
    padding: 12px 14px;
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 16px;
    font-family: 'JetBrains Mono', monospace;
    line-height: 1.7;
}

/* ============= LISTAS DIVERSAS ============= */
.list-divided > * + * { border-top: 1px solid var(--border); }
.list-item {
    padding: 14px 0;
    display: flex;
    align-items: center;
    gap: 12px;
}

.list-item-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: var(--surface-2);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    flex-shrink: 0;
}

.list-item-content { flex: 1; min-width: 0; }
.list-item-title { font-weight: 600; font-size: 13.5px; }
.list-item-sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.list-item-time { font-size: 11px; color: var(--text-light); }

/* ============= GRID UTILITIES ============= */
.grid-2 { display: grid; grid-template-columns: 2fr 1fr; gap: 24px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }

@media (max-width: 1024px) {
    .grid-2 { grid-template-columns: 1fr; }
    .grid-3 { grid-template-columns: 1fr; }
    .form-row { grid-template-columns: 1fr; }
    .sidebar { display: none; }
    .search-box { width: 180px; }
    .page-content { padding: 20px; }
    .topbar { padding: 0 20px; }
}

/* ============= CHAT ============= */
.chat-container {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 0;
    background: var(--surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    overflow: hidden;
    height: calc(100vh - var(--topbar-height) - 64px);
}

.chat-sidebar {
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
}

.chat-sidebar-header {
    padding: 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.chat-list { flex: 1; overflow-y: auto; }

.chat-list-item {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: background 0.15s;
}
.chat-list-item:hover { background: var(--surface-2); }
.chat-list-item.active { background: rgba(249,115,22,0.06); border-left: 3px solid var(--accent); }

.chat-main {
    display: flex;
    flex-direction: column;
}

.chat-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: var(--surface-2);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.chat-message {
    max-width: 70%;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 13.5px;
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}

.chat-message.mine {
    align-self: flex-end;
    background: var(--accent);
    color: white;
}

.chat-message-meta {
    font-size: 10px;
    opacity: 0.7;
    margin-top: 4px;
}

.chat-input {
    padding: 14px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 10px;
    background: var(--surface);
}

.chat-input input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid var(--border-strong);
    border-radius: 999px;
    font-size: 13px;
}

/* ============= EMPTY STATE ============= */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-state svg {
    width: 64px;
    height: 64px;
    color: var(--text-light);
    margin-bottom: 16px;
}

.empty-state h3 {
    font-size: 16px;
    margin-bottom: 6px;
    color: var(--text);
}

/* ============= MODAL ============= */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15,23,42,0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 20px;
}

.modal-overlay.active { display: flex; }

.modal {
    background: var(--surface);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 540px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-xl);
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-title { font-size: 17px; font-weight: 700; }

.modal-body { padding: 24px; }

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* ============= TIMELINE ============= */
.timeline { position: relative; padding-left: 28px; }

.timeline::before {
    content: '';
    position: absolute;
    left: 10px;
    top: 8px;
    bottom: 8px;
    width: 2px;
    background: var(--border);
}

.timeline-item {
    position: relative;
    padding-bottom: 20px;
}

.timeline-item::before {
    content: '';
    position: absolute;
    left: -24px;
    top: 4px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--accent);
    border: 3px solid var(--surface);
    box-shadow: 0 0 0 1px var(--border);
}

.timeline-time {
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.timeline-content {
    font-size: 13px;
}

/* Action buttons row */
.actions-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 12px;
}

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

.filter-tab {
    padding: 6px 14px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    background: var(--surface);
    border: 1px solid var(--border);
    cursor: pointer;
    transition: all 0.15s;
}

.filter-tab.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* ============= SCROLLBAR ============= */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-light); }
