/*
 * Stakko - Theme-aware CSS Architecture
 */

:root {
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --secondary: #14b8a6;
    --dark: #0f172a;
    --dark-muted: #475569;
    --light: #f8fafc;
    --white: #ffffff;
    --surface-soft: #f1f5f9;
    --danger: #ef4444;
    --success: #10b981;
    --warning: #f59e0b;
    --border: #e2e8f0;
    --overlay: rgba(15, 23, 42, 0.55);

    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;

    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 12px 22px -12px rgb(15 23 42 / 0.25);
    --shadow-lg: 0 22px 40px -18px rgb(15 23 42 / 0.28);

    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

html[data-theme="dark"] {
    --primary: #818cf8;
    --primary-hover: #6366f1;
    --secondary: #2dd4bf;
    --dark: #e2e8f0;
    --dark-muted: #94a3b8;
    --light: #020617;
    --white: #0f172a;
    --surface-soft: #111c2d;
    --danger: #f87171;
    --success: #34d399;
    --warning: #fbbf24;
    --border: #22314a;
    --overlay: rgba(2, 6, 23, 0.72);

    --shadow-sm: 0 1px 2px 0 rgb(2 6 23 / 0.35);
    --shadow-md: 0 16px 28px -16px rgb(2 6 23 / 0.7);
    --shadow-lg: 0 26px 44px -20px rgb(2 6 23 / 0.78);
}

html {
    color-scheme: light;
}

html[data-theme="dark"] {
    color-scheme: dark;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-family);
    background-color: var(--light);
    color: var(--dark-muted);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: background-color 0.2s ease, color 0.2s ease;
}

h1, h2, h3, h4, h5, h6 {
    color: var(--dark);
    font-weight: 700;
    line-height: 1.2;
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: var(--transition);
}

a:hover {
    color: var(--primary-hover);
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

main.main-content {
    flex: 1;
    padding: 2rem 0;
}

.navbar {
    background: var(--white);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 50;
    padding: 1rem 0;
    backdrop-filter: blur(12px);
}

.navbar .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.brand {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--primary);
    letter-spacing: -0.5px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.brand.has-logo {
    gap: 0.8rem;
    letter-spacing: 0;
}

.brand-logo {
    display: inline-flex;
    align-items: center;
    justify-content: flex-start;
    flex-shrink: 0;
    height: 46px;
    max-width: min(240px, 52vw);
}

.brand-logo img {
    display: block;
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.brand-name {
    white-space: nowrap;
}

.brand-mark {
    width: 2.2rem;
    height: 2.2rem;
    border-radius: 0.9rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: color-mix(in srgb, var(--primary) 16%, var(--white));
    color: var(--primary);
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--primary) 18%, transparent);
    flex-shrink: 0;
}

.brand-mark i {
    font-size: 1.1rem;
}

.brand-mark img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: inherit;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.nav-links a {
    color: var(--dark-muted);
    font-weight: 500;
}

.nav-links a:hover {
    color: var(--primary);
}

.theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    background: var(--white);
    color: var(--dark);
    width: 44px;
    height: 44px;
    padding: 0;
    border-radius: 999px;
    cursor: pointer;
    font-family: var(--font-family);
    font-size: 0.95rem;
    font-weight: 600;
    transition: var(--transition);
    flex-shrink: 0;
    position: relative;
    overflow: hidden;
}

.theme-toggle:hover {
    border-color: var(--primary);
    color: var(--primary);
    box-shadow: var(--shadow-sm);
    transform: translateY(-1px);
}

.theme-toggle:focus-visible {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 14%, transparent);
}

.theme-toggle i {
    font-size: 1.08rem;
    position: relative;
    z-index: 1;
}

.theme-toggle::before {
    content: "";
    position: absolute;
    inset: 6px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--primary) 8%, transparent);
    opacity: 0;
    transition: var(--transition);
}

.theme-toggle:hover::before,
.theme-toggle:focus-visible::before {
    opacity: 1;
}

.theme-toggle-label {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1rem;
    font-weight: 500;
    border-radius: var(--radius-md);
    border: none;
    cursor: pointer;
    transition: var(--transition);
    font-family: var(--font-family);
    font-size: 0.95rem;
    gap: 0.5rem;
}

.btn-primary {
    background: var(--primary);
    color: #fff !important;
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--dark);
}

.btn-outline:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: color-mix(in srgb, var(--primary) 8%, transparent);
}

.btn-success {
    background: var(--success);
    color: #fff !important;
}

.btn-success:hover {
    filter: brightness(0.95);
}

.btn-danger {
    background: var(--danger);
    color: #fff !important;
}

.form-group {
    margin-bottom: 1.25rem;
}

.form-label {
    display: block;
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: var(--dark);
    font-size: 0.95rem;
}

.form-control {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background-color: var(--white);
    color: var(--dark);
    font-family: var(--font-family);
    transition: var(--transition);
    font-size: 1rem;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 16%, transparent);
}

.alert {
    padding: 1rem;
    border-radius: var(--radius-md);
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 500;
}

.alert-success {
    background-color: color-mix(in srgb, var(--success) 16%, var(--white));
    color: color-mix(in srgb, var(--success) 65%, var(--dark));
    border: 1px solid color-mix(in srgb, var(--success) 40%, var(--border));
}

.alert-error, .alert-danger {
    background-color: color-mix(in srgb, var(--danger) 14%, var(--white));
    color: color-mix(in srgb, var(--danger) 60%, var(--dark));
    border: 1px solid color-mix(in srgb, var(--danger) 36%, var(--border));
}

.alert-warning {
    background-color: color-mix(in srgb, var(--warning) 14%, var(--white));
    color: color-mix(in srgb, var(--warning) 62%, var(--dark));
    border: 1px solid color-mix(in srgb, var(--warning) 34%, var(--border));
}

.card {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    overflow: hidden;
    transition: var(--transition);
}

.card:hover {
    box-shadow: var(--shadow-md);
}

.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }
.text-muted { color: var(--dark-muted); }
.text-primary { color: var(--primary); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-danger { color: var(--danger); }

.m-0 { margin: 0; }
.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 0.75rem; }
.mt-4 { margin-top: 1rem; }
.mt-5 { margin-top: 1.5rem; }
.mt-6 { margin-top: 2rem; }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 0.75rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-5 { margin-bottom: 1.5rem; }
.mb-6 { margin-bottom: 2rem; }
.mb-8 { margin-bottom: 3rem; }

.p-0 { padding: 0; }
.p-1 { padding: 0.25rem; }
.p-2 { padding: 0.5rem; }
.p-3 { padding: 0.75rem; }
.p-4 { padding: 1rem; }
.p-5 { padding: 1.5rem; }
.p-6 { padding: 2rem; }
.p-8 { padding: 3rem; }

.w-full { width: 100%; }
.h-full { height: 100%; }
.d-block { display: block; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.align-start { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.justify-end { justify-content: flex-end; }
.gap-1 { gap: 0.25rem; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }
.gap-5 { gap: 1.25rem; }
.gap-6 { gap: 1.5rem; }
.gap-8 { gap: 2rem; }
.flex-column { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }

.badge {
    display: inline-block;
    padding: 0.25em 0.5em;
    font-size: 0.75em;
    font-weight: 600;
    border-radius: var(--radius-sm);
    background: var(--surface-soft);
    color: var(--dark-muted);
}

.badge-success { background: color-mix(in srgb, var(--success) 16%, var(--white)); color: color-mix(in srgb, var(--success) 70%, var(--dark)); }
.badge-warning { background: color-mix(in srgb, var(--warning) 18%, var(--white)); color: color-mix(in srgb, var(--warning) 65%, var(--dark)); }
.badge-primary { background: color-mix(in srgb, var(--primary) 15%, var(--white)); color: color-mix(in srgb, var(--primary) 65%, var(--dark)); }

.grid {
    display: grid;
    gap: 1.5rem;
}

.grid-cols-1 { grid-template-columns: repeat(1, minmax(0, 1fr)); }

@media (min-width: 768px) {
    .md\:grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .md\:grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .md\:grid-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    .md-col-span-1 { grid-column: span 1 / span 1; }
    .md-col-span-2 { grid-column: span 2 / span 2; }
    .md-col-span-3 { grid-column: span 3 / span 3; }
}

@media (min-width: 1024px) {
    .lg\:grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .lg\:grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .lg\:grid-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    .lg\:col-span-1 { grid-column: span 1 / span 1; }
    .lg\:col-span-2 { grid-column: span 2 / span 2; }
    .lg\:col-span-3 { grid-column: span 3 / span 3; }
}

.footer {
    background: var(--white);
    border-top: 1px solid var(--border);
    padding: 3rem 0;
    margin-top: auto;
}

.footer-text {
    text-align: center;
    color: var(--dark-muted);
    font-size: 0.875rem;
}

.ph,
.ph-bold,
.ph-fill,
.ph-light,
.ph-thin,
.ph-duotone {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    vertical-align: middle;
}

.icon-shell {
    width: 2.5rem;
    height: 2.5rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.95rem;
    background: color-mix(in srgb, var(--primary) 12%, var(--white));
    color: var(--primary);
    border: 1px solid color-mix(in srgb, var(--primary) 14%, var(--border));
    flex-shrink: 0;
}

.icon-shell i {
    font-size: 1.1rem;
}

.table-responsive {
    width: 100%;
    overflow-x: auto;
}

html[data-theme="dark"] .data-table th,
html[data-theme="dark"] .data-table td,
html[data-theme="dark"] .users-table th,
html[data-theme="dark"] .users-table td {
    border-color: var(--border) !important;
    color: var(--dark-muted);
}

html[data-theme="dark"] .data-table tr:hover td,
html[data-theme="dark"] .users-table tr:hover td {
    background: var(--surface-soft) !important;
}

html[data-theme="dark"] [style*="background:#fff"],
html[data-theme="dark"] [style*="background: #fff"],
html[data-theme="dark"] [style*="background:#ffffff"],
html[data-theme="dark"] [style*="background: #ffffff"],
html[data-theme="dark"] [style*="background-color:#fff"],
html[data-theme="dark"] [style*="background-color: #fff"],
html[data-theme="dark"] [style*="background-color:#ffffff"],
html[data-theme="dark"] [style*="background-color: #ffffff"] {
    background: var(--white) !important;
}

html[data-theme="dark"] [style*="background:#f8fafc"],
html[data-theme="dark"] [style*="background: #f8fafc"],
html[data-theme="dark"] [style*="background:#f1f5f9"],
html[data-theme="dark"] [style*="background: #f1f5f9"],
html[data-theme="dark"] [style*="background-color:#f8fafc"],
html[data-theme="dark"] [style*="background-color: #f8fafc"],
html[data-theme="dark"] [style*="background-color:#f1f5f9"],
html[data-theme="dark"] [style*="background-color: #f1f5f9"] {
    background: var(--surface-soft) !important;
}

html[data-theme="dark"] [style*="#e2e8f0"] {
    border-color: var(--border) !important;
}

html[data-theme="dark"] [style*="color:#1e293b"],
html[data-theme="dark"] [style*="color: #1e293b"],
html[data-theme="dark"] [style*="color:#0f172a"],
html[data-theme="dark"] [style*="color: #0f172a"] {
    color: var(--dark) !important;
}

html[data-theme="dark"] [style*="color:#64748b"],
html[data-theme="dark"] [style*="color: #64748b"],
html[data-theme="dark"] [style*="color:#475569"],
html[data-theme="dark"] [style*="color: #475569"],
html[data-theme="dark"] [style*="color:#94a3b8"],
html[data-theme="dark"] [style*="color: #94a3b8"] {
    color: var(--dark-muted) !important;
}

html[data-theme="dark"] .hero-content,
html[data-theme="dark"] .premium-card,
html[data-theme="dark"] .benefit-card,
html[data-theme="dark"] .pricing-box,
html[data-theme="dark"] .stats-banner,
html[data-theme="dark"] .form-card,
html[data-theme="dark"] .chat-input-area,
html[data-theme="dark"] .chat-messages,
html[data-theme="dark"] .filter-bar,
html[data-theme="dark"] .users-stats-strip,
html[data-theme="dark"] .user-card,
html[data-theme="dark"] .stat-card {
    background: var(--white) !important;
    border-color: var(--border) !important;
}

html[data-theme="dark"] .chat-bubble {
    box-shadow: none;
}

html[data-theme="dark"] .bg-light {
    background: var(--white) !important;
    color: var(--dark) !important;
}

html[data-theme="dark"] .search-box,
html[data-theme="dark"] .sort-radio,
html[data-theme="dark"] .sticky-sidebar {
    color: var(--dark-muted);
}

@media (max-width: 860px) {
    .navbar .container {
        flex-direction: column;
        align-items: stretch;
    }

    .brand-logo {
        height: 40px;
        max-width: min(210px, 68vw);
    }

    .nav-links {
        justify-content: flex-start;
    }
}
