/* Real Estate CRM - Modern Theme (brand primary RGB 133, 78, 242 — #854ef2) */

:root {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --text-primary: #f8fafc;
    --text-secondary: #cbd5e1;
    --menu-primary: #854ef2;
    --brand-rgb: 133, 78, 242;
    --brand-600: #854ef2;
    --brand-500: #a270f8;
    --brand-700: #7240d8;
    --card-bg: rgba(30, 41, 59, 0.8);
    --card-border: rgba(148, 163, 184, 0.1);
    --rainbow-gradient: linear-gradient(90deg,
        #ff0000 0%, #ff8000 14%, #ffff00 28%, #80ff00 42%,
        #00ff00 57%, #00ff80 71%, #00ffff 85%, #0080ff 100%
    );
}

body.dark, .dark {
    background: #0f172a !important;
    color: #f8fafc !important;
}

html, body { overflow-x: hidden; }

.app-logo, .app-favicon { object-fit: contain !important; max-width: 100%; max-height: 100%; }

/* Rainbow Card - Animated border, dark theme */
.rainbow-card, .stat-card {
    position: relative;
    background: #1e293b !important;
    color: #f8fafc !important;
    border-radius: 16px;
    padding: 1.5rem;
    border: 1px solid rgba(148, 163, 184, 0.12);
    overflow: hidden;
    backdrop-filter: blur(10px);
    transition: all 0.3s ease;
}

.rainbow-card h2, .rainbow-card h3, .rainbow-card p, .rainbow-card span, .rainbow-card a,
.rainbow-card td, .rainbow-card th, .rainbow-card label,
.stat-card h2, .stat-card h3, .stat-card p, .stat-card span, .stat-card a,
.stat-card td, .stat-card th, .stat-card label { color: #f8fafc !important; }

.rainbow-card .text-gray-400, .rainbow-card .text-gray-500, .rainbow-card th,
.stat-card .text-gray-400, .stat-card .text-gray-500, .stat-card th { color: #94a3b8 !important; }

.rainbow-card a:hover, .stat-card a:hover { color: #d4b8ff !important; }

.rainbow-card .text-purple-400, .stat-card .text-purple-400 { color: #bc97fb !important; }
.rainbow-card .text-blue-400, .stat-card .text-blue-400 { color: #60a5fa !important; }
.rainbow-card .text-green-500, .stat-card .text-green-500 { color: #34d399 !important; }
.rainbow-card .text-amber-400, .stat-card .text-amber-400 { color: #fbbf24 !important; }
.rainbow-card .text-emerald-400, .stat-card .text-emerald-400 { color: #34d399 !important; }

.rainbow-card::before, .stat-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 2px;
    background: var(--rainbow-gradient);
    background-size: 200% 100%;
    animation: rainbow-flow 3s linear infinite;
}

@keyframes rainbow-flow {
    0% { background-position: 0% 50%; }
    100% { background-position: 200% 50%; }
}

.rainbow-card:hover, .stat-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.4);
}

.rainbow-card:hover::before, .stat-card:hover::before {
    animation-duration: 1.5s;
    height: 2px;
}

.sidebar-gradient {
    background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%) !important;
    border-right: 1px solid rgba(148, 163, 184, 0.1);
}

.sidebar-gradient .menu-heading { color: #bc97fb !important; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; font-size: 0.75rem; }

body:not(.dark) .rainbow-card, body:not(.dark) .stat-card {
    background: #1e293b !important;
    color: #f8fafc !important;
    border: 1px solid rgba(148, 163, 184, 0.15);
}

.btn-primary {
    background: linear-gradient(135deg, #a270f8 0%, #854ef2 50%, #7240d8 100%);
    color: white !important;
    border: none;
    border-radius: 8px;
    padding: 0.75rem 1.5rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 20px rgba(var(--brand-rgb), 0.35);
    color: white !important;
}

.form-input {
    background: #ffffff;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    color: #111827;
    padding: 0.75rem 1rem;
    width: 100%;
}

.dark .form-input { background: #374151; border-color: #4b5563; color: #f9fafb; }
.form-input:focus { outline: none; border-color: #854ef2; box-shadow: 0 0 0 3px rgba(var(--brand-rgb), 0.22); }
select.form-input { appearance: menulist; cursor: pointer; min-height: 2.5rem; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: #1e293b; border-radius: 4px; }
::-webkit-scrollbar-thumb { background: #475569; border-radius: 4px; }

@media (max-width: 640px) { .rainbow-card, .stat-card { padding: 1rem; } }

/* Dashboard stat grid — responsive layout & fluid type on all screen sizes */
.dashboard-stat-grid {
    width: 100%;
    min-width: 0;
}
.dashboard-stat-grid .stat-card {
    container-type: inline-size;
    container-name: dash-stat;
    min-width: 0;
    padding: clamp(0.75rem, 2.5vw, 1.25rem) !important;
}
.dashboard-stat-grid .stat-card > .flex.items-center {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: auto auto;
    column-gap: clamp(0.25rem, 1.5vw, 0.5rem);
    row-gap: 0.125rem;
    align-items: start;
    min-width: 0;
}
.dashboard-stat-grid .stat-card > .flex > .min-w-0 {
    display: contents;
}
.dashboard-stat-grid .stat-card > .flex > .min-w-0 > .text-sm,
.dashboard-stat-grid .stat-card > .flex > .min-w-0 > .stat-card-label {
    grid-column: 1;
    grid-row: 1;
    font-size: clamp(0.6875rem, 2.8cqi, 0.8125rem);
    line-height: 1.25;
    margin: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    align-self: center;
}
.dashboard-stat-grid .stat-card > .flex > .min-w-0 > .text-xs {
    grid-column: 1 / -1;
    grid-row: 3;
    font-size: clamp(0.625rem, 2.4cqi, 0.75rem);
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
}
.dashboard-stat-grid .stat-card > .flex > .min-w-0 > .stat-card-value {
    grid-column: 1 / -1;
    grid-row: 2;
    margin-top: 0.125rem;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: clamp(15px, 6cqi, 20px);
    font-weight: 700;
    line-height: 1.25;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.02em;
}
@supports not (container-type: inline-size) {
    .dashboard-stat-grid .stat-card > .flex > .min-w-0 > .stat-card-value {
        font-size: clamp(15px, 1.4vw + 0.65rem, 18px);
    }
}
.dashboard-stat-grid .stat-card > a {
    font-size: clamp(0.6875rem, 2.5cqi, 0.8125rem);
    margin-top: 0.5rem;
    display: inline-block;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.dashboard-stat-grid .stat-card > .flex > div.w-12,
.dashboard-stat-grid .stat-card > .flex > .stat-card-icon {
    grid-column: 2;
    grid-row: 1;
    width: clamp(1.5rem, 8cqi, 1.875rem) !important;
    height: clamp(1.5rem, 8cqi, 1.875rem) !important;
    min-width: 1.5rem;
    min-height: 1.5rem;
    border-radius: 0.5rem;
    align-self: center;
    flex-shrink: 0;
}
.dashboard-stat-grid .stat-card > .flex > div.w-12 i,
.dashboard-stat-grid .stat-card > .flex > .stat-card-icon i {
    font-size: clamp(0.6875rem, 4cqi, 0.875rem) !important;
}
/* Viewport fallbacks when cards are very narrow (many columns) or very wide (mobile) */
@media (max-width: 639px) {
    .dashboard-stat-grid .stat-card > .flex > .min-w-0 > .stat-card-value {
        font-size: clamp(17px, 4.5vw, 20px);
    }
}
@media (min-width: 640px) and (max-width: 1023px) {
    .dashboard-stat-grid .stat-card > .flex > .min-w-0 > .stat-card-value {
        font-size: clamp(16px, 2.2vw, 18px);
    }
}
@media (min-width: 1024px) and (max-width: 1535px) {
    .dashboard-stat-grid .stat-card > .flex > .min-w-0 > .stat-card-value {
        font-size: clamp(15px, 1.1vw, 17px);
    }
}
@media (min-width: 1536px) {
    .dashboard-stat-grid .stat-card > .flex > .min-w-0 > .stat-card-value {
        font-size: clamp(16px, 5.5cqi, 18px);
    }
}
@media (max-width: 1023px) {
    .dashboard-stat-grid .stat-card:hover {
        transform: none;
        box-shadow: none;
    }
}
.sidebar-menu-scroll { flex: 1 1 0; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; }

@media (max-width: 768px) {
    .hero-slider .hero-prev, .hero-slider .hero-next { width: 40px; height: 40px; left: 8px; right: 8px; font-size: 0.875rem; }
}
@media (max-width: 640px) {
    .hero-slider .hero-prev, .hero-slider .hero-next { width: 36px; height: 36px; left: 4px; right: 4px; }
}
.table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-responsive table { min-width: 600px; }
