:root {
    --bg-primary: #000000;
    --bg-elevated: #0a0a0a;
    --bg-input: #111111;
    --border-color: rgba(255, 255, 255, 0.1);
    --border-strong: rgba(255, 255, 255, 0.18);
    --text-primary: #ffffff;
    --text-secondary: #d4d4d4;
    --text-muted: #8a8a8a;
    --accent: #e31e24;
    --accent-dark: #c41920;
    --accent-glow: rgba(227, 30, 36, 0.25);
    --success: #22c55e;
    --warning: #fbbf24;
    --info: #3b82f6;
    --danger: #ef4444;
    --sidebar-width: 260px;
}

* { box-sizing: border-box; }

body {
    background: var(--bg-primary);
    color: var(--text-primary);
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    margin: 0;
    min-height: 100vh;
}

h1, h2, h3, h4, h5, h6 {
    color: var(--text-primary);
}

/* Auth */
.auth-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--bg-primary);
}

.auth-wrapper { width: 100%; max-width: 420px; padding: 20px; }

.auth-card {
    background: var(--bg-elevated);
    border: 1px solid var(--border-strong);
    border-radius: 16px;
    padding: 2.5rem;
    box-shadow: 0 0 0 1px rgba(227, 30, 36, 0.08);
}

.auth-logo { max-width: 100%; max-height: 70px; margin-bottom: 0.75rem; }
.auth-title { color: var(--text-primary); font-size: 1.25rem; font-weight: 700; text-align: center; margin-bottom: 0.25rem; }
.auth-subtitle { text-align: center; margin-bottom: 1.5rem; color: var(--text-muted); }

/* Layout */
.app-wrapper { display: flex; min-height: 100vh; background: var(--bg-primary); }

.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-primary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 1000;
    transition: transform 0.3s;
}

.sidebar-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    text-align: center;
}

.sidebar-logo { max-width: 100%; max-height: 48px; }
.sidebar-title { display: block; color: var(--text-muted); font-size: 0.65rem; margin-top: 0.5rem; font-weight: 600; letter-spacing: 0.5px; text-transform: uppercase; white-space: nowrap; }

.sidebar-nav { flex: 1; padding: 1rem 0; overflow-y: auto; }
.sidebar-footer { padding: 1rem; border-top: 1px solid var(--border-color); }

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1.5rem;
    color: var(--text-secondary);
    text-decoration: none;
    transition: all 0.2s;
    border-left: 3px solid transparent;
}

.sidebar-nav .nav-link i,
.sidebar-footer .nav-link i {
    width: 1.25rem;
    text-align: center;
    flex-shrink: 0;
}

.nav-link:hover, .nav-link.active {
    color: #fff;
    background: rgba(227, 30, 36, 0.12);
    border-left-color: var(--accent);
}

.app-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    background: var(--bg-primary);
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
}

.page-title { font-size: 1.25rem; font-weight: 600; margin: 0; color: var(--text-primary); }
.topbar-right { display: flex; align-items: center; gap: 1rem; }

.main-content { padding: 1.5rem; flex: 1; background: var(--bg-primary); }

/* Cards */
.card-dark {
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    overflow: hidden;
}

.card-dark .card-header {
    background: transparent;
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 1.25rem;
}

.card-dark .card-header h5,
.card-dark .card-header h6 {
    color: var(--text-primary);
    font-weight: 600;
    margin: 0;
}

.card-dark .card-body {
    background: transparent;
    color: var(--text-primary);
}

.card-dark strong {
    color: var(--text-secondary);
}

/* Stats */
.stat-card {
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.stat-card:hover {
    border-color: rgba(227, 30, 36, 0.4);
    box-shadow: 0 0 20px rgba(227, 30, 36, 0.1);
}

.stat-card-link { text-decoration: none; color: inherit; cursor: pointer; }

.stat-icon {
    width: 48px; height: 48px;
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.25rem; color: #fff;
}

.stat-value { display: block; font-size: 1.5rem; font-weight: 700; color: #fff; }
.stat-label { color: var(--text-muted); font-size: 0.8rem; }

/* Forms */
.form-control, .form-select {
    background: var(--bg-input);
    border: 1px solid var(--border-strong);
    color: var(--text-primary);
    border-radius: 8px;
    padding: 0.6rem 0.85rem;
}

.form-control::placeholder {
    color: var(--text-muted);
    opacity: 1;
}

.form-control:focus, .form-select:focus {
    background: var(--bg-input);
    border-color: var(--accent);
    color: var(--text-primary);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.form-control:disabled {
    background: var(--bg-elevated);
    color: var(--text-muted);
    border-color: var(--border-color);
}

.input-group-text {
    background: var(--bg-input);
    border-color: var(--border-strong);
    color: var(--text-secondary);
}

.form-label {
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.35rem;
}

.req {
    color: var(--accent) !important;
    font-weight: 700;
    margin-left: 0.15rem;
}

.form-check-label {
    color: var(--text-secondary);
}

.form-check-input {
    background-color: var(--bg-input);
    border-color: var(--border-strong);
}

.form-check-input:checked {
    background-color: var(--accent);
    border-color: var(--accent);
}

/* Buttons */
.btn-primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #ffffff;
    font-weight: 600;
}

.btn-primary:hover {
    background: var(--accent-dark);
    border-color: var(--accent-dark);
    color: #ffffff;
}

.btn-glow {
    box-shadow: 0 4px 15px var(--accent-glow);
}

.btn-outline-light {
    border-color: var(--border-strong);
    color: var(--text-secondary);
}

.btn-outline-light:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: var(--text-secondary);
    color: var(--text-primary);
}

.btn-outline-primary {
    border-color: var(--accent);
    color: var(--accent);
}

.btn-outline-primary:hover {
    background: var(--accent);
    color: #fff;
}

/* Tables */
.table-dark {
    --bs-table-bg: transparent;
    --bs-table-color: var(--text-primary);
    --bs-table-border-color: var(--border-color);
    --bs-table-hover-bg: rgba(227, 30, 36, 0.05);
    --bs-table-striped-bg: rgba(255, 255, 255, 0.02);
}

.table-dark thead th {
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    border-bottom-color: var(--border-strong);
    background: transparent;
}

.table-dark td {
    border-color: var(--border-color);
    vertical-align: middle;
}

/* Estados */
.badge.estado-pendente { background: var(--warning) !important; color: #000; text-transform: uppercase; }
.badge.estado-em_andamento { background: var(--info) !important; color: #fff; text-transform: uppercase; }
.badge.estado-pronto { background: var(--success) !important; color: #000; text-transform: uppercase; }
.badge.estado-cancelado { background: #6b7280 !important; color: #fff; text-transform: uppercase; }

.table-dark .badge {
    text-transform: uppercase;
}

.text-accent { color: var(--accent) !important; }

.btn-accent {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.btn-outline-accent {
    border-color: var(--accent);
    color: var(--accent);
}

.btn-outline-accent:hover {
    background: var(--accent);
    color: #fff;
}

/* Créditos */
.creditos-badge {
    background: rgba(227, 30, 36, 0.15);
    color: var(--accent);
    padding: 0.4rem 1rem;
    border-radius: 20px;
    font-weight: 600;
    font-size: 0.85rem;
    border: 1px solid rgba(227, 30, 36, 0.25);
}

.creditos-badge-lg {
    font-size: 1.5rem;
    color: var(--accent);
    font-weight: 700;
}

.creditos-total {
    font-size: 2rem;
    font-weight: 700;
    color: var(--accent);
}

.border-warning {
    border-color: rgba(227, 30, 36, 0.4) !important;
}

/* Chat */
.chat-card { max-height: 500px; display: flex; flex-direction: column; }
.chat-messages {
    height: 350px;
    overflow-y: auto;
    padding: 1rem;
    background: var(--bg-primary);
}

.chat-message { margin-bottom: 0.75rem; display: flex; }
.chat-own { justify-content: flex-end; }
.chat-other { justify-content: flex-start; }

.chat-bubble {
    max-width: 75%;
    padding: 0.75rem 1rem;
    border-radius: 12px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
}

.chat-own .chat-bubble {
    background: rgba(227, 30, 36, 0.12);
    border-color: rgba(227, 30, 36, 0.35);
}

.chat-bubble p { margin: 0.25rem 0; color: var(--text-primary); }
.chat-bubble strong { font-size: 0.8rem; color: var(--accent); }
.chat-time { display: block; font-size: 0.7rem; color: var(--text-muted); margin-top: 0.25rem; }

.chat-input {
    border-top: 1px solid var(--border-color);
    background: var(--bg-elevated);
}

/* Language switcher */
.lang-switch {
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.15rem;
}

.lang-switch-auth {
    display: flex;
    justify-content: center;
    width: 100%;
    max-width: 200px;
    margin: 0 auto 1.25rem;
    padding: 0.25rem;
    gap: 0.25rem;
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid var(--border-strong);
    border-radius: 999px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.lang-switch-auth .lang-btn {
    flex: 1;
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    padding: 0.45rem 0.85rem;
    border-radius: 999px;
    line-height: 1.1;
}

.lang-switch-auth .lang-btn:not(.active):hover {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-primary);
}

.lang-switch-auth .lang-btn.active {
    background: var(--accent);
    color: #fff;
    box-shadow: 0 0 0 1px rgba(227, 30, 36, 0.35), 0 4px 14px rgba(227, 30, 36, 0.35);
}

.lang-btn {
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    padding: 0.3rem 0.55rem;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.lang-btn:hover {
    color: var(--text-primary);
}

.lang-btn.active {
    background: var(--accent);
    color: #fff;
}

/* Notifications */
.notification-panel {
    width: 380px;
    max-height: 420px;
    overflow-y: auto;
    overflow-x: hidden;
    background: var(--bg-elevated);
    border: 1px solid var(--border-strong);
    border-radius: 10px;
    padding: 0;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
}

.notification-panel .dropdown-header {
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--border-color);
    background: rgba(255, 255, 255, 0.02);
}

.notification-panel .dropdown-header h6 {
    font-size: 0.82rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: var(--text-secondary);
}

.notification-panel #markAllNotificationsRead {
    font-size: 0.75rem;
    text-decoration: none;
}

.notification-item {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.9rem 1rem;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    color: var(--text-primary);
    text-decoration: none;
    white-space: normal !important;
    word-break: break-word;
    transition: background 0.2s;
}

.notification-item:last-child {
    border-bottom: none;
}

.notification-item:hover {
    background: rgba(227, 30, 36, 0.08);
    color: var(--text-primary);
}

.notification-item.unread {
    background: rgba(227, 30, 36, 0.04);
    border-left: 3px solid var(--accent);
    padding-left: calc(1rem - 3px);
}

.notification-item-icon {
    width: 34px;
    height: 34px;
    border-radius: 9px;
    background: rgba(227, 30, 36, 0.12);
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 0.85rem;
}

.notification-item-body {
    flex: 1;
    min-width: 0;
}

.notification-item-title {
    display: block;
    font-weight: 600;
    font-size: 0.86rem;
    color: var(--text-primary);
    line-height: 1.35;
    margin-bottom: 0.2rem;
}

.notification-item-message {
    display: block;
    font-size: 0.8rem;
    color: var(--text-secondary);
    line-height: 1.45;
}

.notification-item-time {
    display: block;
    font-size: 0.68rem;
    color: var(--text-muted);
    margin-top: 0.35rem;
    letter-spacing: 0.02em;
}

.notification-empty {
    padding: 1.5rem 1rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.btn-icon {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 1.2rem;
    position: relative;
    padding: 0.5rem;
}

.btn-icon:hover { color: var(--text-primary); }

.btn-icon .badge {
    position: absolute;
    top: 0; right: 0;
    font-size: 0.65rem;
}

.user-info {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
    text-decoration: none;
    transition: color 0.2s;
}

.user-info:hover {
    color: var(--text-primary);
}

/* Toast */
#toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toast-notification {
    padding: 1rem 1.25rem;
    border-radius: 10px;
    color: #fff;
    font-size: 0.9rem;
    min-width: 280px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.5);
    animation: slideIn 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.toast-success { background: #166534; border-left: 4px solid var(--success); }
.toast-error { background: #991b1b; border-left: 4px solid var(--danger); }
.toast-warning { background: #854d0e; border-left: 4px solid var(--warning); }
.toast-info { background: #1e40af; border-left: 4px solid var(--info); }

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.activity-item {
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-secondary);
}

/* Responsive */
@media (max-width: 991px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .app-content { margin-left: 0; }
    .topbar { padding: 0.7rem 0.9rem; }
    .topbar-right { gap: 0.45rem; }
    .page-title {
        font-size: 1.05rem;
        max-width: min(42vw, 11rem);
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    .main-content { padding: 1rem; }
    .user-info span { display: none; }
    .user-info { gap: 0; padding: 0.35rem; }
    .creditos-badge {
        font-size: 0.78rem;
        padding: 0.3rem 0.55rem;
    }
    .lang-switch { transform: scale(0.92); transform-origin: right center; }
    .notification-panel {
        width: min(calc(100vw - 1.5rem), 360px);
        max-width: calc(100vw - 1.5rem);
    }
}

@media (max-width: 575px) {
    .topbar { padding: 0.55rem 0.7rem; }
    .topbar-left { min-width: 0; gap: 0.35rem; }
    .page-title { max-width: 34vw; font-size: 0.95rem; }
    .main-content { padding: 0.75rem; }
    .card-dark .card-header { padding: 0.75rem 0.9rem; }
    .card-dark .card-body { padding: 0.9rem; }
    .card-dark.mb-4 { margin-bottom: 0.85rem !important; }
    .stat-card { padding: 0.9rem; }
    .stat-value { font-size: 1.25rem; }

    /* Novo pedido — opções com área de toque maior */
    #novoPedidoForm .form-check {
        display: flex;
        align-items: center;
        gap: 0.65rem;
        min-height: 48px;
        margin-bottom: 0.45rem !important;
        padding: 0.55rem 0.75rem;
        border: 1px solid var(--border-color);
        border-radius: 10px;
        background: rgba(255, 255, 255, 0.02);
    }
    #novoPedidoForm .form-check-input {
        width: 1.2rem;
        height: 1.2rem;
        margin-top: 0;
        flex-shrink: 0;
    }
    #novoPedidoForm .form-check-label {
        flex: 1;
        line-height: 1.3;
        padding-top: 0;
    }
    #novoPedidoForm .creditos-total {
        font-size: 1.6rem;
    }
    #novoPedidoForm .btn-glow {
        min-height: 48px;
        font-size: 1rem;
    }
    .sidebar-toggle {
        padding: 0.35rem 0.5rem !important;
        font-size: 1.25rem;
    }
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 3px; }

.dropdown-menu {
    background: var(--bg-elevated);
    border: 1px solid var(--border-strong);
}

.dropdown-item { color: var(--text-primary); }
.dropdown-item:hover { background: rgba(227, 30, 36, 0.1); color: var(--accent); }
.dropdown-header { color: var(--text-muted); }

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

/* Override Bootstrap defaults que criam cinzas estranhos */
.card { background: transparent; }
.bg-primary { background-color: var(--accent) !important; }
.bg-secondary { background-color: #333 !important; }

/* Paginação */
.pagination-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
    padding: 0.25rem 0;
}

.pagination-dark .page-link {
    background: var(--bg-elevated);
    border-color: var(--border-strong);
    color: var(--text-primary);
    min-width: 2.25rem;
    text-align: center;
}

.pagination-dark .page-link:hover {
    background: rgba(227, 30, 36, 0.15);
    border-color: var(--accent);
    color: var(--accent);
}

.pagination-dark .page-item.active .page-link {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.pagination-dark .page-item.disabled .page-link {
    background: var(--bg-primary);
    border-color: var(--border-strong);
    color: var(--text-muted);
    opacity: 0.6;
}

/* Resumo do pedido */
.pedido-resumo {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.pedido-resumo-section + .pedido-resumo-section {
    padding-top: 0.25rem;
}

.pedido-resumo-title {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    font-weight: 600;
    margin: 0 0 0.85rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.pedido-resumo-title i {
    color: var(--accent);
    font-size: 0.8rem;
}

.pedido-resumo-grid {
    display: grid;
    gap: 0.85rem 1.5rem;
}

.pedido-resumo-grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.pedido-resumo-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.pedido-resumo-grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.pedido-resumo-grid-sub {
    margin-top: 0.85rem;
}

.pedido-resumo-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    min-width: 0;
}

.pedido-resumo-item-inline {
    flex: 1;
    min-width: 140px;
}

.pedido-resumo-item-valor {
    align-items: flex-end;
    text-align: right;
}

.pedido-resumo-label {
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    font-weight: 600;
}

.pedido-resumo-value {
    color: var(--text-primary);
    font-size: 0.95rem;
    line-height: 1.4;
    word-break: break-word;
}

.pedido-resumo-matricula {
    font-weight: 600;
    letter-spacing: 0.04em;
}

.pedido-resumo-servico-box {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 1rem 1.25rem;
    margin-top: 0.85rem;
}

.pedido-resumo-servico-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    flex-wrap: wrap;
    gap: 1rem;
}

.pedido-resumo-servico-badge {
    font-size: 0.85rem;
    font-weight: 600;
    padding: 0.45em 0.75em;
}

.pedido-resumo-valor-total {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--accent);
    line-height: 1;
}

.pedido-resumo-extras {
    margin-top: 0.85rem;
    padding-top: 0.85rem;
    border-top: 1px solid var(--border-color);
}

.pedido-resumo-extras-label {
    display: block;
    margin-bottom: 0.5rem;
}

.pedido-resumo-extras-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
}

.pedido-resumo-extra-badge {
    font-size: 0.8rem;
    font-weight: 500;
    padding: 0.4em 0.7em;
}

.pedido-resumo-observacoes {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.85rem 1rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.5;
    white-space: pre-wrap;
}

@media (max-width: 991px) {
    .pedido-resumo-grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 575px) {
    .pedido-resumo-grid-2,
    .pedido-resumo-grid-3,
    .pedido-resumo-grid-4 {
        grid-template-columns: 1fr;
    }

    .pedido-resumo-item-valor {
        align-items: flex-start;
        text-align: left;
    }

    .pedido-resumo-servico-header {
        flex-direction: column;
        align-items: flex-start;
    }
}
