/* =====================================================
   CARREX DESIGN SYSTEM - CSS Global
   ===================================================== */

/* ---------- CSS Variables ---------- */
:root {
    --cx-primary: #1a56db;
    --cx-primary-hover: #1648b8;
    --cx-primary-light: #e8effd;
    --cx-success: #059669;
    --cx-success-hover: #047857;
    --cx-success-light: #ecfdf5;
    --cx-danger: #dc2626;
    --cx-danger-hover: #b91c1c;
    --cx-danger-light: #fef2f2;
    --cx-warning: #f59e0b;
    --cx-warning-light: #fffbeb;
    --cx-info: #0ea5e9;
    --cx-info-light: #f0f9ff;
    --cx-dark: #111827;
    --cx-gray-50: #f9fafb;
    --cx-gray-100: #f3f4f6;
    --cx-gray-200: #e5e7eb;
    --cx-gray-300: #d1d5db;
    --cx-gray-400: #9ca3af;
    --cx-gray-500: #6b7280;
    --cx-gray-600: #4b5563;
    --cx-gray-700: #374151;
    --cx-gray-800: #1f2937;
    --cx-gray-900: #111827;
    --cx-body-bg: #f0f2f5;
    --cx-card-radius: 16px;
    --cx-card-shadow: 0 1px 3px rgba(0,0,0,0.06), 0 4px 12px rgba(0,0,0,0.04);
    --cx-card-shadow-hover: 0 4px 6px rgba(0,0,0,0.06), 0 10px 24px rgba(0,0,0,0.08);
    --cx-transition: all 0.2s ease;
    --cx-font: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }

body {
    font-family: var(--cx-font);
    background-color: var(--cx-body-bg);
    color: var(--cx-gray-800);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ---------- Navbar ---------- */
.cx-navbar {
    background: linear-gradient(135deg, var(--cx-gray-900) 0%, #1e293b 100%) !important;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    padding: 0.6rem 0;
}

.cx-navbar .navbar-brand {
    font-size: 1.35rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: #fff !important;
}

.cx-navbar .nav-link {
    color: rgba(255,255,255,0.7) !important;
    font-weight: 500;
    font-size: 0.9rem;
    padding: 0.55rem 0.85rem !important;
    border-radius: 8px;
    transition: var(--cx-transition);
}

.cx-navbar .nav-link:hover,
.cx-navbar .nav-link.active {
    color: #fff !important;
    background: rgba(255,255,255,0.1);
}

.cx-navbar .nav-link.active {
    background: rgba(255,255,255,0.15);
}

.cx-navbar .btn-danger {
    background: var(--cx-danger);
    border: none;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.8rem;
    padding: 0.4rem 0.9rem;
}

.cx-navbar .btn-danger:hover {
    background: var(--cx-danger-hover);
}

.cx-navbar .user-info {
    color: rgba(255,255,255,0.6);
    font-size: 0.85rem;
}

.cx-navbar .user-info strong {
    color: #fff;
    font-weight: 600;
}

/* ---------- Page Header ---------- */
.cx-page-header {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.cx-page-header h1,
.cx-page-header h2 {
    font-weight: 700;
    color: var(--cx-gray-900);
    margin: 0;
    font-size: 1.5rem;
}

@media (min-width: 768px) {
    .cx-page-header {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }
}

/* ---------- Cards ---------- */
.cx-card {
    background: #fff;
    border: 1px solid var(--cx-gray-200);
    border-radius: var(--cx-card-radius);
    box-shadow: var(--cx-card-shadow);
    transition: var(--cx-transition);
    overflow: hidden;
}

.cx-card-header {
    padding: 1rem 1.25rem;
    font-weight: 700;
    font-size: 1rem;
    border-bottom: 1px solid var(--cx-gray-200);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.cx-card-body {
    padding: 1.25rem;
}

@media (min-width: 768px) {
    .cx-card-body {
        padding: 1.5rem;
    }
}

/* ---------- Dashboard Nav Cards ---------- */
.cx-nav-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    text-decoration: none;
    color: var(--cx-gray-700);
    background: #fff;
    border: 1px solid var(--cx-gray-200);
    border-radius: var(--cx-card-radius);
    padding: 1.5rem 1rem;
    box-shadow: var(--cx-card-shadow);
    transition: var(--cx-transition);
    height: 100%;
}

.cx-nav-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--cx-card-shadow-hover);
    color: var(--cx-gray-900);
    border-color: var(--cx-primary);
}

.cx-nav-card .cx-icon-box {
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 14px;
    font-size: 1.5rem;
    margin-bottom: 0.75rem;
    color: #fff;
}

.cx-nav-card .cx-card-label {
    font-weight: 600;
    font-size: 0.9rem;
}

/* ---------- Tables ---------- */
.cx-table {
    width: 100%;
    margin-bottom: 0;
}

.cx-table thead {
    background: var(--cx-gray-800);
    color: #fff;
}

.cx-table thead th {
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 0.85rem 1rem;
    white-space: nowrap;
    border: none;
}

.cx-table tbody td {
    padding: 0.8rem 1rem;
    border-bottom: 1px solid var(--cx-gray-100);
    vertical-align: middle;
    font-size: 0.9rem;
}

.cx-table tbody tr:last-child td {
    border-bottom: none;
}

.cx-table tbody tr:hover {
    background: var(--cx-gray-50);
}

/* Mobile responsive table */
@media (max-width: 768px) {
    .cx-table-responsive thead { display: none; }

    .cx-table-responsive tbody tr {
        display: block;
        background: #fff;
        margin-bottom: 0.75rem;
        border-radius: 12px;
        border: 1px solid var(--cx-gray-200);
        box-shadow: 0 1px 4px rgba(0,0,0,0.04);
        overflow: hidden;
    }

    .cx-table-responsive tbody td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 0.7rem 1rem;
        border-bottom: 1px solid var(--cx-gray-100);
        font-size: 0.88rem;
    }

    .cx-table-responsive tbody td:last-child {
        border-bottom: none;
        background: var(--cx-gray-50);
        justify-content: center;
        padding: 0.85rem 1rem;
    }

    .cx-table-responsive tbody td::before {
        content: attr(data-label);
        font-weight: 700;
        color: var(--cx-gray-500);
        text-transform: uppercase;
        font-size: 0.7rem;
        letter-spacing: 0.03em;
        flex-shrink: 0;
        margin-right: 1rem;
    }
}

/* ---------- Badges ---------- */
.cx-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.3em 0.75em;
    border-radius: 50px;
    font-weight: 600;
    font-size: 0.78rem;
    letter-spacing: 0.01em;
    line-height: 1.4;
}

.cx-badge-success { background: var(--cx-success-light); color: var(--cx-success); }
.cx-badge-warning { background: var(--cx-warning-light); color: #92400e; }
.cx-badge-danger  { background: var(--cx-danger-light); color: var(--cx-danger); }
.cx-badge-info    { background: var(--cx-info-light); color: #0369a1; }
.cx-badge-primary { background: var(--cx-primary-light); color: var(--cx-primary); }
.cx-badge-dark    { background: var(--cx-gray-100); color: var(--cx-gray-700); }

/* Role badges */
.cx-badge-ADMIN       { background: #fef2f2; color: #dc2626; }
.cx-badge-AJUDANTE    { background: #eff6ff; color: #2563eb; }
.cx-badge-FUNCIONARIO { background: #ecfdf5; color: #059669; }
.cx-badge-CLIENTE     { background: #f3f4f6; color: #6b7280; }

/* ---------- Buttons ---------- */
.cx-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    font-weight: 600;
    border-radius: 10px;
    padding: 0.6rem 1.2rem;
    font-size: 0.9rem;
    border: none;
    cursor: pointer;
    transition: var(--cx-transition);
    text-decoration: none;
    line-height: 1.5;
}

.cx-btn:active { transform: scale(0.97); }

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

.cx-btn-success { background: var(--cx-success); color: #fff; }
.cx-btn-success:hover { background: var(--cx-success-hover); color: #fff; }

.cx-btn-danger { background: var(--cx-danger); color: #fff; }
.cx-btn-danger:hover { background: var(--cx-danger-hover); color: #fff; }

.cx-btn-warning { background: var(--cx-warning); color: #fff; }
.cx-btn-warning:hover { background: #d97706; color: #fff; }

.cx-btn-info { background: var(--cx-info); color: #fff; }
.cx-btn-info:hover { background: #0284c7; color: #fff; }

.cx-btn-outline {
    background: transparent;
    border: 2px solid var(--cx-gray-300);
    color: var(--cx-gray-600);
}
.cx-btn-outline:hover {
    background: var(--cx-gray-100);
    border-color: var(--cx-gray-400);
    color: var(--cx-gray-800);
}

.cx-btn-lg {
    padding: 0.8rem 1.5rem;
    font-size: 1rem;
}

.cx-btn-sm {
    padding: 0.35rem 0.75rem;
    font-size: 0.8rem;
}

@media (max-width: 768px) {
    .cx-btn-mobile-full { width: 100%; }
    .cx-btn-mobile-flex { flex: 1; }
}

/* ---------- Forms ---------- */
.cx-form-label {
    font-weight: 600;
    color: var(--cx-gray-700);
    font-size: 0.88rem;
    margin-bottom: 0.35rem;
}

.cx-section-header {
    background: linear-gradient(135deg, var(--cx-gray-50), var(--cx-gray-100));
    padding: 0.6rem 1rem;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--cx-gray-700);
    border-left: 3px solid var(--cx-primary);
    margin-bottom: 1rem;
}

/* Prevent iOS zoom on inputs */
.form-control,
.form-select {
    font-size: 16px !important;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--cx-primary);
    box-shadow: 0 0 0 3px rgba(26,86,219,0.12);
}

/* ---------- Section Divider ---------- */
.cx-divider {
    font-weight: 700;
    color: var(--cx-gray-500);
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--cx-gray-200);
}

/* ---------- Summary Boxes ---------- */
.cx-summary-box {
    border-radius: 14px;
    padding: 1.25rem;
    text-align: center;
    color: #fff;
    position: relative;
    overflow: hidden;
}

.cx-summary-box::before {
    content: '';
    position: absolute;
    top: -20px;
    right: -20px;
    width: 80px;
    height: 80px;
    background: rgba(255,255,255,0.1);
    border-radius: 50%;
}

.cx-summary-box .cx-summary-value {
    font-size: 1.8rem;
    font-weight: 800;
    line-height: 1.2;
}

.cx-summary-box .cx-summary-label {
    font-size: 0.82rem;
    opacity: 0.85;
    font-weight: 500;
}

/* ---------- Delivery Cards ---------- */
.cx-delivery-card {
    background: #fff;
    border: 1px solid var(--cx-gray-200);
    border-radius: 12px;
    border-left: 5px solid var(--cx-success);
    box-shadow: var(--cx-card-shadow);
    transition: var(--cx-transition);
}

.cx-delivery-card.status-pendente { border-left-color: var(--cx-warning); }
.cx-delivery-card.status-entregue { border-left-color: var(--cx-success); }
.cx-delivery-card.status-cancelado { border-left-color: var(--cx-danger); }

/* ---------- Alert ---------- */
.cx-empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
    color: var(--cx-gray-400);
}

.cx-empty-state .cx-empty-icon {
    font-size: 3rem;
    margin-bottom: 0.75rem;
    display: block;
}

.cx-empty-state p {
    font-size: 0.95rem;
    margin: 0;
}

/* ---------- Utilities ---------- */
.cx-container { max-width: 1200px; margin: 0 auto; padding: 1.25rem 1rem; }

@media (min-width: 768px) {
    .cx-container { padding: 2rem 1.5rem; }
}

.cx-text-mono { font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace; }
.cx-text-muted { color: var(--cx-gray-500); }
.cx-text-sm { font-size: 0.85rem; }
.cx-fw-bold { font-weight: 700; }
.cx-mt-0 { margin-top: 0; }

/* ---------- Mobile optimizations ---------- */
@media (max-width: 576px) {
    .cx-navbar .navbar-brand { font-size: 1.2rem; }

    .cx-page-header h1,
    .cx-page-header h2 { font-size: 1.25rem; }

    .cx-card-body { padding: 1rem; }

    .cx-nav-card { padding: 1.15rem 0.75rem; }
    .cx-nav-card .cx-icon-box { width: 48px; height: 48px; font-size: 1.3rem; }
    .cx-nav-card .cx-card-label { font-size: 0.82rem; }
}

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--cx-gray-300); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--cx-gray-400); }

/* ---------- Focus visible ---------- */
:focus-visible {
    outline: 2px solid var(--cx-primary);
    outline-offset: 2px;
}

/* ---------- Print ---------- */
@media print {
    .cx-navbar,
    .cx-no-print { display: none !important; }
    body { background: #fff; }
    .cx-card { box-shadow: none; border: 1px solid #ddd; }
}
