/* ============================================================
   Portal do Colaborador TGA Sistemas — Estilos Globais
   ============================================================ */

:root {
    --primary:      #2563eb;
    --primary-dark: #1d4ed8;
    --success:      #16a34a;
    --danger:       #dc2626;
    --warning:      #f59e0b;
    --info:         #0891b2;
    --light-bg:     #f1f5f9;
    --border-color: #e2e8f0;
    --sidebar-bg:   #0063C6;
    --sidebar-w:    260px;
    --topbar-h:     58px;
}

* { box-sizing: border-box; }

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--light-bg);
    margin: 0;
}

/* ── Portal layout ─────────────────────────────────────── */
.portal-body { overflow-x: hidden; }

/* Sidebar — fixo, ocultável com toggle */
.sidebar {
    position: fixed;
    top: 0; left: 0;
    width: var(--sidebar-w);
    height: 100vh;
    background: var(--sidebar-bg);
    z-index: 1050;
    overflow-y: auto;
    overflow-x: hidden;
    transform: translateX(0);
    transition: transform .28s cubic-bezier(.4,0,.2,1);
    display: flex;
    flex-direction: column;
    box-shadow: 2px 0 16px rgba(0,0,0,.18);
}

/* Desktop: sidebar oculto via toggle */
.sidebar.sidebar-hidden { transform: translateX(-100%); }

/* Mobile: sidebar inicia oculto, abre como overlay */
@media (max-width: 767.98px) {
    .sidebar { transform: translateX(-100%); box-shadow: 4px 0 24px rgba(0,0,0,.35); }
    .sidebar.sidebar-open  { transform: translateX(0); }
    .sidebar.sidebar-hidden { transform: translateX(-100%); }
}

.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.12); border-radius: 2px; }

/* Backdrop escurecido */
.sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 1040;
    opacity: 0;
    pointer-events: none;
    transition: opacity .28s ease;
}
.sidebar-backdrop.active {
    opacity: 1;
    pointer-events: all;
}

/* Botão fechar (×) dentro do sidebar */
.sidebar-close-btn {
    background: none;
    border: none;
    color: rgba(255,255,255,.35);
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 6px;
    font-size: 1.05rem;
    line-height: 1;
    flex-shrink: 0;
    transition: color .15s, background .15s;
}
.sidebar-close-btn:hover { color: white; background: rgba(255,255,255,.1); }

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px 16px;
    border-bottom: 1px solid rgba(255,255,255,.08);
    flex-shrink: 0;
}

.sidebar-logo {
    width: 36px; height: 36px;
    object-fit: contain;
    flex-shrink: 0;
}

.sidebar-app-name {
    color: white;
    font-weight: 700;
    font-size: .9rem;
    line-height: 1.2;
}

.sidebar-app-sub {
    color: #94a3b8;
    font-size: .72rem;
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    border-bottom: 1px solid rgba(255,255,255,.08);
    flex-shrink: 0;
}

.sidebar-user-avatar {
    font-size: 1.8rem;
    color: #94a3b8;
    flex-shrink: 0;
}

.sidebar-user-name {
    color: #e2e8f0;
    font-size: .82rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 140px;
}

.badge-sm { font-size: .65rem; padding: 2px 6px; }

/* Sidebar menu */
.sidebar-menu {
    list-style: none;
    padding: 10px 0;
    margin: 0;
    flex: 1;
}

.sidebar-menu-label {
    color: rgb(255, 255, 255);
    font-size: .65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .1em;
    padding: 18px 20px 5px;
    display: flex;
    align-items: center;
    cursor: pointer;
    user-select: none;
    transition: color .15s;
}
.sidebar-menu-label:hover { color: rgba(255,255,255,.5); }

.sidebar-group-chevron {
    margin-left: auto;
    font-size: .65rem;
    opacity: .45;
    transition: transform .22s ease, opacity .22s ease;
}
.sidebar-menu-label.group-collapsed .sidebar-group-chevron {
    transform: rotate(-90deg);
}
.sidebar-group-hidden { display: none !important; }

.sidebar-menu-divider {
    border-top: 1px solid rgba(255,255,255,.08);
    margin: 8px 0;
}

.sidebar-menu-item > a {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 9px 16px 9px 20px;
    color: #f2f2f2;
    text-decoration: none;
    font-size: .85rem;
    border-radius: 8px;
    margin: 1px 10px;
    transition: background .18s, color .18s, box-shadow .18s;
    white-space: nowrap;
}

.sidebar-menu-item > a i { font-size: 1.05rem; flex-shrink: 0; }

.sidebar-menu-item > a:hover {
    background: rgba(255,255,255,.07);
    color: #e2e8f0;
}

.sidebar-menu-item.active > a {
    background: rgb(6, 61, 179);
    color: white;
    box-shadow: inset 3px 0 0 var(--primary);
}

/* Chevron de dropdown nos submenus */
.sidebar-chevron {
    margin-left: auto;
    font-size: .7rem;
    opacity: .4;
    transition: transform .22s ease, opacity .22s ease;
    flex-shrink: 0;
}
.sidebar-menu-item.submenu-open > a .sidebar-chevron {
    transform: rotate(90deg);
    opacity: .75;
}

.text-danger-sidebar { color: #f87171 !important; }
.text-danger-sidebar:hover { background: rgba(248,113,113,.15) !important; color: #fca5a5 !important; }

/* Submenu */
.sidebar-submenu {
    list-style: none;
    padding: 2px 0 6px;
    margin: 0;
    display: none;
}
.sidebar-submenu.show { display: block; }
.sidebar-submenu li a {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 16px 6px 40px;
    color: rgba(255, 255, 255, 0.913);
    text-decoration: none;
    font-size: .8rem;
    border-radius: 6px;
    margin: 0 10px;
    transition: color .15s, background .15s;
}
.sidebar-submenu li a:hover {
    color: #cbd5e1;
    background: rgba(255,255,255,.05);
}
.sidebar-submenu li a i { font-size: .8rem; flex-shrink: 0; }

/* Main content area */
.main-wrapper {
    margin-left: var(--sidebar-w);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin-left .28s cubic-bezier(.4,0,.2,1);
}
/* Desktop: expande quando sidebar está oculto */
.main-wrapper.sidebar-hidden { margin-left: 0; }

/* Mobile: sem margin (sidebar é overlay) */
@media (max-width: 767.98px) {
    .main-wrapper { margin-left: 0 !important; }
}

/* Top bar */
.top-bar {
    height: var(--topbar-h);
    background: white;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: 0 1px 3px rgba(0,0,0,.05);
}

.top-bar-left { display: flex; align-items: center; gap: 14px; }
.top-bar-right { display: flex; align-items: center; gap: 12px; }

.sidebar-toggle {
    background: none;
    border: none;
    cursor: pointer;
    color: #64748b;
    font-size: 1.3rem;
    padding: 4px 8px;
    border-radius: 6px;
    transition: background .15s;
}
.sidebar-toggle:hover { background: var(--light-bg); }

.top-bar-title {
    font-weight: 600;
    color: #1e293b;
    font-size: .95rem;
}

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

/* Footer */
.portal-footer {
    text-align: center;
    color: #94a3b8;
    font-size: .78rem;
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    background: white;
    margin-left: 0;
}

@media (max-width: 768px) {
    .page-content { padding: 16px; }
}

/* ── Cards / stats ─────────────────────────────────────── */
.stat-card {
    border: none;
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(0,0,0,.06);
    transition: transform .2s;
}
.stat-card:hover { transform: translateY(-2px); }
.stat-card .card-body { padding: 20px; }

.stat-icon {
    width: 48px; height: 48px;
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.3rem;
}
.stat-value { font-size: 1.8rem; font-weight: 700; line-height: 1; }
.stat-label { color: #64748b; font-size: .85rem; }

/* ── Tables ────────────────────────────────────────────── */
.table-custom { border-radius: 8px; overflow: hidden; box-shadow: 0 1px 6px rgba(0,0,0,.05); }
.table-custom thead th { background: var(--primary); color: white; font-weight: 600; border: none; padding: 12px; }
.table-custom tbody td { padding: 10px 12px; vertical-align: middle; }

/* ── Schedule Table ────────────────────────────────────── */
.schedule-table {
    border-collapse: separate;
    border-spacing: 0;
    width: 100%;
    font-size: .85rem;
}
.schedule-table thead th {
    background: var(--primary);
    color: white;
    padding: 10px 8px;
    text-align: center;
    font-weight: 600;
    position: sticky; top: 0; z-index: 10;
    border: 1px solid var(--primary-dark);
}
.schedule-table tbody td {
    padding: 6px 4px;
    text-align: center;
    border: 1px solid var(--border-color);
    vertical-align: middle;
    transition: all .2s;
}
.schedule-table tbody tr:hover td { background-color: #f0f7ff; }

.time-cell {
    background: #f8fafc;
    font-weight: 600;
    color: #475569;
    white-space: nowrap;
    min-width: 90px;
}

/* Slot states */
.slot-available { background: #f0fdf4; cursor: pointer; }
.slot-available:hover { background: #bbf7d0 !important; transform: scale(1.02); }
.slot-booked { background: #fef2f2; color: #991b1b; cursor: default; font-size: .75rem; }
.slot-booked .booking-name { font-weight: 600; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 120px; margin: 0 auto; }
.slot-past { background: #f1f5f9; color: #94a3b8; cursor: not-allowed; }
.slot-unavailable { background: #f1f5f9; color: #cbd5e1; }

.slot-selected { background: #dbeafe !important; outline: 2px solid #3b82f6; color: #1d4ed8; }
.slot-selected:hover { background: #bfdbfe !important; }

.booking-action-bar {
    position: fixed; bottom: 24px; left: 50%;
    transform: translateX(-50%);
    background: #1e293b; color: white;
    padding: 13px 22px; border-radius: 50px;
    display: flex; align-items: center; gap: 20px;
    box-shadow: 0 8px 32px rgba(0,0,0,.3);
    z-index: 1050; white-space: nowrap;
    animation: slideUp .25s ease-out;
}
@keyframes slideUp {
    from { transform: translateX(-50%) translateY(16px); opacity: 0; }
    to   { transform: translateX(-50%) translateY(0);   opacity: 1; }
}

/* ── Week navigation ───────────────────────────────────── */
.week-nav {
    display: flex; align-items: center;
    justify-content: center; gap: 15px; margin-bottom: 20px;
}
.week-nav .btn { border-radius: 50%; width: 40px; height: 40px; display: flex; align-items: center; justify-content: center; padding: 0; }
.week-label { font-size: 1.1rem; font-weight: 600; color: #1e293b; min-width: 280px; text-align: center; }
.schedule-wrapper { overflow-x: auto; border-radius: 12px; box-shadow: 0 2px 12px rgba(0,0,0,.06); background: white; }

/* ── Modal ─────────────────────────────────────────────── */
.modal-header {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white; border: none;
}
.modal-header .btn-close { filter: brightness(0) invert(1); }

/* ── Badges ────────────────────────────────────────────── */
.badge-external { background: #fbbf24; color: #92400e; }
.badge-internal { background: #60a5fa; color: #1e3a5f; }

/* ── Mercadorias status ─────────────────────────────────── */
.status-card {
    border-left: 4px solid transparent;
    transition: all .2s;
}
.status-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,.1); }
.status-aguardando  { border-left-color: var(--warning); }
.status-recebida    { border-left-color: var(--info); }
.status-entregue    { border-left-color: var(--primary); }
.status-confirmada  { border-left-color: var(--success); }
.status-cancelada   { border-left-color: #94a3b8; }

/* ── Login page ────────────────────────────────────────── */
.login-container { min-width: 420px; max-width: 480px; margin: 80px auto; }
.login-card { border: none; border-radius: 16px; box-shadow: 0 10px 40px rgba(0,0,0,.1); overflow: hidden; }
.login-header { background: linear-gradient(135deg, #234993, #398ACC); color: white; padding: 30px; text-align: center; }
.login-header h2 { margin: 0; font-weight: 700; }
.login-header p { margin: 5px 0 0; opacity: .85; }
.login-body { padding: 30px; }

/* ── External / public pages ───────────────────────────── */
.external-header {
    background: linear-gradient(135deg, var(--primary), #7c3aed);
    color: white; padding: 40px 0; text-align: center; margin-bottom: 30px;
}
.external-header h1 { font-weight: 700; margin-bottom: 10px; }
.external-header p { opacity: .9; font-size: 1.1rem; }

/* ── Animations ────────────────────────────────────────── */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}
.fade-in { animation: fadeIn .3s ease-out; }

/* ── Print ─────────────────────────────────────────────── */
@media print {
    .sidebar, .top-bar, .portal-footer, .btn, .no-print, .booking-action-bar { display: none !important; }
    .main-wrapper { margin-left: 0 !important; }
    .schedule-table { font-size: .7rem; }
}

/* ── Responsive ────────────────────────────────────────── */
@media (max-width: 768px) {
    .schedule-table { font-size: .7rem; }
    .stat-value { font-size: 1.4rem; }
    .week-label { font-size: .9rem; min-width: auto; }
    .booking-action-bar { bottom: 10px; padding: 10px 14px; gap: 10px; font-size: .82rem; }
    .login-container { min-width: auto; max-width: 100%; margin: 20px auto; }
}
