/* ── Variables ───────────────────────────────────────── */
:root {
    --accent-red: #c44536;
    --gradient-red: linear-gradient(135deg, #c44536, #d95f4e);
    --dark-bg: #0a0a0a;
    --dark-card: #111111;
    --dark-card-border: rgba(255, 255, 255, 0.07);
    --text-secondary: #a0a0a0;
    --text-muted: #5a5a5a;
}

/* ── Base ────────────────────────────────────────────── */
body {
    font-family: 'Raleway', sans-serif;
    background: var(--dark-bg);
    min-height: 100vh;
    padding: 110px 20px 100px;
}

/* ── Background decorations ──────────────────────────── */
.page-bg-glow {
    position: fixed;
    top: 0;
    right: 0;
    width: 65vw;
    height: 65vh;
    background: radial-gradient(ellipse at 75% 15%, rgba(196, 69, 54, 0.07) 0%, transparent 60%);
    pointer-events: none;
    z-index: 0;
}

.page-bg-grid {
    position: fixed;
    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: 50px 50px;
    pointer-events: none;
    z-index: 0;
    -webkit-mask-image: radial-gradient(ellipse at center, black 5%, transparent 75%);
    mask-image: radial-gradient(ellipse at center, black 5%, transparent 75%);
}

/* ── Navbar ──────────────────────────────────────────── */
.navbar {
    background-color: rgba(10, 10, 10, 0.95) !important;
    backdrop-filter: blur(10px);
    padding: 1rem 0;
    box-shadow: 0 2px 20px rgba(0, 0, 0, 0.5);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.navbar-brand {
    display: flex;
    align-items: center;
}

.navbar-logo-icon {
    height: 40px;
    width: 40px;
    padding: 5px;
    background: var(--gradient-red);
    border-radius: 10px;
    margin-right: 0.75rem;
    object-fit: contain;
}

.navbar-logo-text {
    height: 40px;
}

/* ── Page container ──────────────────────────────────── */
.dash-container {
    max-width: 1200px;
    margin: 0 auto;
    position: relative;
    z-index: 1;
}

/* ── Welcome header ──────────────────────────────────── */
.dash-welcome {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.welcome-left {
    display: flex;
    align-items: center;
    gap: 1.25rem;
}

.dash-workshop-logo {
    width: 60px;
    height: 60px;
    border-radius: 12px;
    object-fit: cover;
    border: 2px solid rgba(255,255,255,0.08);
    flex-shrink: 0;
}

.dash-eyebrow {
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    color: var(--accent-red);
    background: rgba(196, 69, 54, 0.1);
    border: 1px solid rgba(196, 69, 54, 0.25);
    border-radius: 20px;
    padding: 0.25rem 0.8rem;
    display: inline-block;
    margin-bottom: 0.4rem;
}

.dash-title {
    color: #fff;
    font-size: 1.9rem;
    font-weight: 700;
    margin: 0 0 0.2rem;
    line-height: 1.2;
}

.dash-title .gradient-text {
    background: linear-gradient(135deg, #c44536, #e07b6e);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.dash-subtitle {
    color: var(--text-muted);
    font-size: 0.83rem;
    margin: 0;
    text-transform: capitalize;
}

.welcome-actions {
    display: flex;
    gap: 0.6rem;
    flex-wrap: wrap;
}

.btn-quick {
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--dark-card-border);
    color: #ddd !important;
    border-radius: 50px;
    font-size: 0.82rem;
    font-weight: 600;
    padding: 0.5rem 1rem;
    text-decoration: none !important;
    transition: all 0.2s;
    font-family: 'Raleway', sans-serif;
    display: inline-flex;
    align-items: center;
}

.btn-quick:hover {
    background: rgba(196, 69, 54, 0.15);
    border-color: rgba(196, 69, 54, 0.3);
    color: #fff !important;
}

/* ── Stats grid ──────────────────────────────────────── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 1rem;
    margin-bottom: 1.75rem;
}

.stat-card {
    background: var(--dark-card);
    border: 1px solid var(--dark-card-border);
    border-radius: 14px;
    padding: 1.1rem 1.2rem;
    display: flex;
    align-items: center;
    gap: 0.9rem;
    transition: border-color 0.2s, box-shadow 0.2s;
    position: relative;
}

.stat-card:hover {
    border-color: rgba(196, 69, 54, 0.25);
    box-shadow: 0 4px 20px rgba(196, 69, 54, 0.07);
}

.stat-card--alert {
    border-color: rgba(220, 38, 38, 0.35) !important;
    background: rgba(196, 69, 54, 0.08) !important;
}

.stat-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: rgba(255,255,255,0.04);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
    color: var(--icon-color, var(--accent-red));
    border: 1px solid rgba(255,255,255,0.06);
}

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

.stat-value {
    font-size: 1.7rem;
    font-weight: 800;
    color: #fff;
    line-height: 1;
    margin-bottom: 0.25rem;
}

.stat-label {
    font-size: 0.73rem;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.stat-link {
    color: var(--text-muted);
    font-size: 0.75rem;
    text-decoration: none;
    transition: color 0.15s;
    flex-shrink: 0;
}

.stat-link:hover {
    color: var(--accent-red);
}

/* ── Main grid ───────────────────────────────────────── */
.dash-main-grid {
    display: grid;
    grid-template-columns: 1fr 360px;
    gap: 1.25rem;
    margin-bottom: 1.75rem;
}

.dash-col-main,
.dash-col-side {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

/* ── Dashboard cards ─────────────────────────────────── */
.dash-card {
    background: var(--dark-card);
    border: 1px solid var(--dark-card-border);
    border-radius: 14px;
    overflow: hidden;
}

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

.dash-card-title {
    color: #fff;
    font-size: 0.9rem;
    font-weight: 700;
    display: flex;
    align-items: center;
}

.dash-card-title i {
    color: var(--accent-red);
}

.dash-card-subtitle {
    color: var(--text-muted);
    font-size: 0.75rem;
}

.dash-card-link {
    color: var(--text-muted);
    font-size: 0.78rem;
    text-decoration: none;
    transition: color 0.15s;
}

.dash-card-link:hover {
    color: var(--accent-red);
}

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

.dash-card-body.p-0 {
    padding: 0;
}

/* ── Chart wrappers ──────────────────────────────────── */
.chart-wrap {
    position: relative;
    height: 220px;
}

.chart-wrap--pie {
    height: 260px;
    max-width: 320px;
    margin: 0 auto;
}

.chart-empty {
    padding: 2.5rem 1rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
    font-style: italic;
}

/* ── Top colors ──────────────────────────────────────── */
.top-colors-list {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.color-bar-row {
    display: flex;
    align-items: center;
    gap: 0.9rem;
}

.color-swatch {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    border: 1px solid rgba(255,255,255,0.12);
    flex-shrink: 0;
}

.color-bar-info {
    flex: 1;
    min-width: 0;
}

.color-bar-label {
    font-size: 0.82rem;
    color: #ddd;
    font-weight: 600;
    margin-bottom: 0.3rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.color-bar-track {
    height: 5px;
    background: rgba(255,255,255,0.06);
    border-radius: 3px;
    overflow: hidden;
}

.color-bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.6s ease;
    opacity: 0.8;
}

.color-bar-count {
    font-size: 0.78rem;
    color: var(--text-muted);
    flex-shrink: 0;
    min-width: 24px;
    text-align: right;
}

/* ── Agenda list ─────────────────────────────────────── */
.agenda-list {
    display: flex;
    flex-direction: column;
}

.agenda-item {
    display: flex;
    align-items: center;
    gap: 0.9rem;
    padding: 0.85rem 1.1rem;
    border-bottom: 1px solid rgba(255,255,255,0.04);
    transition: background 0.15s;
}

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

.agenda-item:hover {
    background: rgba(255,255,255,0.02);
}

.agenda-time {
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--accent-red);
    min-width: 44px;
    flex-shrink: 0;
}

.agenda-info {
    flex: 1;
    min-width: 0;
}

.agenda-service {
    font-size: 0.88rem;
    color: #fff;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.agenda-client {
    font-size: 0.76rem;
    color: var(--text-muted);
    margin-top: 0.15rem;
}

.agenda-badge {
    font-size: 0.68rem;
    font-weight: 700;
    padding: 0.2rem 0.55rem;
    border-radius: 20px;
    flex-shrink: 0;
    text-transform: capitalize;
}

.appt-pendiente   { background: rgba(217,119,6,0.15);  color: #fbbf24; border: 1px solid rgba(217,119,6,0.3); }
.appt-confirmado  { background: rgba(37,99,235,0.15);  color: #60a5fa; border: 1px solid rgba(37,99,235,0.3); }
.appt-en-proceso  { background: rgba(196,69,54,0.15);  color: #e07b6e; border: 1px solid rgba(196,69,54,0.3); }
.appt-completado  { background: rgba(22,163,74,0.15);  color: #4ade80; border: 1px solid rgba(22,163,74,0.3); }
.appt-cancelado   { background: rgba(74,74,74,0.2);    color: #9ca3af; border: 1px solid rgba(74,74,74,0.4); }

/* ── Recent clients ──────────────────────────────────── */
.recent-clients-list {
    display: flex;
    flex-direction: column;
}

.rclient-item {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.8rem 1.1rem;
    border-bottom: 1px solid rgba(255,255,255,0.04);
    text-decoration: none !important;
    transition: background 0.15s;
}

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

.rclient-item:hover {
    background: rgba(255,255,255,0.025);
}

.rclient-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(196,69,54,0.1);
    border: 1px solid rgba(196,69,54,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent-red);
    font-size: 0.82rem;
    flex-shrink: 0;
}

.rclient-info {
    flex: 1;
    min-width: 0;
}

.rclient-name {
    font-size: 0.88rem;
    color: #fff;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.rclient-vehicle {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.1rem;
}

.rclient-wa {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(21,140,52,0.15);
    border: 1px solid rgba(21,140,52,0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #4ade80;
    font-size: 0.88rem;
    text-decoration: none;
    flex-shrink: 0;
    transition: all 0.15s;
}

.rclient-wa:hover {
    background: rgba(21,140,52,0.3);
    color: #86efac;
}

/* ── Activity feed ───────────────────────────────────── */
.activity-feed {
    display: flex;
    flex-direction: column;
}

.activity-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1.1rem;
    border-bottom: 1px solid rgba(255,255,255,0.04);
}

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

.activity-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
}

.activity-icon {
    font-size: 0.82rem;
    flex-shrink: 0;
    width: 20px;
    text-align: center;
}

.activity-text {
    flex: 1;
    font-size: 0.82rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.activity-when {
    font-size: 0.72rem;
    color: var(--text-muted);
    flex-shrink: 0;
}

/* ── CRM nav bar (bottom shortcuts) ──────────────────── */
.crm-nav-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    padding: 1rem 0;
    border-top: 1px solid var(--dark-card-border);
    margin-top: 0.5rem;
}

.crm-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.3rem;
    padding: 0.7rem 1.2rem;
    border-radius: 12px;
    color: var(--text-muted) !important;
    text-decoration: none !important;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    transition: all 0.2s;
    min-width: 78px;
    text-align: center;
}

.crm-nav-item i {
    font-size: 1.1rem;
}

.crm-nav-item:hover {
    background: rgba(196,69,54,0.1);
    color: var(--accent-red) !important;
}

/* ── Auth Loader ─────────────────────────────────────── */
#authLoader {
    position: fixed;
    inset: 0;
    background: var(--dark-bg);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity 0.3s;
}

#authLoader.hidden {
    opacity: 0;
    pointer-events: none;
}

.auth-loader-spinner {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 3px solid rgba(196, 69, 54, 0.2);
    border-top-color: var(--accent-red);
    animation: spin 0.8s linear infinite;
    margin-bottom: 1rem;
}

.auth-loader-text {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin: 0;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ── Responsive ──────────────────────────────────────── */
@media (max-width: 900px) {
    .dash-main-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .dash-title {
        font-size: 1.5rem;
    }

    .dash-welcome {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .welcome-actions {
        width: 100%;
        flex-direction: column;
        gap: 0.5rem;
    }

    .btn-quick {
        width: 100%;
        justify-content: center;
    }
}

@media (max-width: 380px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
}
