/* Shadcn-inspired Clean Dark Theme (Zinc) */
:root {
    --background: #09090b;
    --foreground: #fafafa;
    --card: #09090b;
    --card-foreground: #fafafa;
    --popover: #09090b;
    --popover-foreground: #fafafa;
    --primary: #fafafa;
    --primary-foreground: #18181b;
    --secondary: #27272a;
    --secondary-foreground: #fafafa;
    --muted: #27272a;
    --muted-foreground: #a1a1aa;
    --accent: #27272a;
    --accent-foreground: #fafafa;
    --destructive: #7f1d1d;
    --destructive-foreground: #fafafa;
    --border: #27272a;
    --input: #27272a;
    --ring: #d4d4d8;
    --success: #22c55e;
    --radius: 0.5rem;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    border-color: var(--border);
}

body {
    background-color: var(--background);
    color: var(--foreground);
    font-family: 'Outfit', sans-serif;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
    line-height: 1.5;
}

/* Fix dark mode date picker icon */
::-webkit-calendar-picker-indicator {
    filter: invert(1);
    opacity: 0.6;
    cursor: pointer;
    transition: opacity 0.2s;
}

::-webkit-calendar-picker-indicator:hover {
    opacity: 1;
}

/* Container Layout */
.container {
    width: 100%;
    margin-right: auto;
    margin-left: auto;
    padding-right: 2rem;
    padding-left: 2rem;
    max-width: 1400px;
}

@media (min-width: 1400px) {
    .container {
        max-width: 1400px;
    }
}

/* Navigation */
.nav {
    border-bottom: 1px solid var(--border);
    background-color: rgba(9, 9, 11, 0.8);
    /* Translucent */
    backdrop-filter: blur(8px);
    position: sticky;
    top: 0;
    z-index: 50;
    width: 100%;
}

.nav-inner {
    display: flex;
    height: 3.5rem;
    /* 56px */
    align-items: center;
    gap: 1.5rem;
}

.nav-brand {
    font-weight: 700;
    font-size: 1.125rem;
    letter-spacing: -0.025em;
    color: var(--foreground);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    /* Remove underline */
    margin-right: auto;
}

.nav-brand span {
    color: var(--primary);
    /* Minimalist white/primary */
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.nav-links a {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--muted-foreground);
    text-decoration: none;
    transition: color 0.2s;
}

.nav-links a:hover,
.nav-links a.active {
    color: var(--foreground);
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.nav-user {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--foreground);
    background: var(--secondary);
    padding: 0.25rem 0.75rem;
    border-radius: var(--radius);
}

/* User Dropdown */
.user-dropdown {
    position: relative;
}

.user-dropdown-trigger {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.25rem 0.5rem;
    background: var(--secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s;
    color: var(--foreground);
    font-size: 0.875rem;
    font-weight: 500;
}

.user-dropdown-trigger:hover {
    background: var(--accent);
    border-color: var(--ring);
}

.user-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid transparent;
    /* Prepare for ring */
    transition: border-color 0.2s ease;
}

.avatar-ring-green {
    border-color: #22c55e;
}

.avatar-ring-red {
    border-color: #ef4444;
}

.user-name {
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dropdown-arrow {
    transition: transform 0.2s;
    opacity: 0.6;
}

.user-dropdown-trigger:hover .dropdown-arrow {
    opacity: 1;
}

.user-dropdown-menu {
    position: absolute;
    top: calc(100% + 0.5rem);
    right: 0;
    min-width: 180px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.4);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: all 0.2s ease;
    z-index: 100;
    padding: 0.5rem 0;
}

.user-dropdown-menu.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 1rem;
    color: var(--foreground);
    text-decoration: none;
    font-size: 0.875rem;
    transition: background 0.15s;
}

.dropdown-item:hover {
    background: var(--accent);
}

.dropdown-item svg {
    opacity: 0.7;
    flex-shrink: 0;
}

.dropdown-item:hover svg {
    opacity: 1;
}

.dropdown-divider {
    height: 1px;
    background: var(--border);
    margin: 0.5rem 0;
}

.dropdown-item-danger {
    color: #f87171;
}

.dropdown-item-danger:hover {
    background: rgba(239, 68, 68, 0.15);
}


/* Page Content */
.page-content {
    padding-top: 2rem;
    padding-bottom: 2rem;
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.header h1 {
    font-size: 1.875rem;
    font-weight: 700;
    letter-spacing: -0.025em;
    color: var(--foreground);
}

/* Controls */
.controls select {
    height: 2.5rem;
    /* 40px */
    background-color: var(--card);
    /* Match card background for cleaner look */
    color: var(--foreground);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0 3rem 0 1rem;
    /* Increased padding-right for custom arrow space */
    font-size: 0.875rem;
    font-family: 'Outfit', sans-serif;
    cursor: pointer;
    outline: none;
    min-width: 180px;
    transition: all 0.2s ease;

    /* Custom Arrow */
    -webkit-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12' fill='none' stroke='%23a1a1aa' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3e%3cpath d='M2.5 4.5L6 8L9.5 4.5'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    /* Moves arrow 1rem from the right edge */
    background-size: 12px 12px;
}

.controls select:focus {
    border-color: var(--ring);
}

/* Grid System */
.grid {
    display: grid;
    grid-template-columns: repeat(1, 1fr);
    gap: 1.5rem;
}

@media (min-width: 768px) {
    .grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Cards */
.card {
    border: 1px solid var(--border);
    background-color: var(--card);
    color: var(--card-foreground);
    border-radius: var(--radius);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    min-width: 0;
    /* Fix grid item overflow */
}

.card h2 {
    font-size: 1rem;
    /* 16px */
    font-weight: 600;
    letter-spacing: -0.01em;
    color: var(--foreground);
    margin-bottom: 1.25rem;
}

.card.full-width {
    grid-column: 1 / -1;
}

.chart-container {
    position: relative;
    flex-grow: 1;
    min-height: 300px;
    width: 100%;
    overflow: hidden;
    /* Prevent canvas blow-out */
}

/* Stats Row (KPIs) */
.stats-row {
    display: flex;
    gap: 3rem;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.stat {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.stat-value {
    font-size: 2.25rem;
    font-weight: 700;
    letter-spacing: -0.05em;
    color: var(--foreground);
    line-height: 1;
}

.stat-label {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--muted-foreground);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Auth Pages */
.auth-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: calc(100vh - 3.5rem);
    padding: 1rem;
}

.auth-card {
    width: 100%;
    max-width: 350px;
    text-align: center;
    padding: 2rem;
    border: 1px solid var(--border);
    background-color: var(--card);
    border-radius: var(--radius);
}

.button-discord {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 2.5rem;
    padding-left: 1rem;
    padding-right: 1rem;
    background-color: #5865F2;
    color: #fff;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: var(--radius);
    text-decoration: none;
    transition: background-color 0.2s;
    border: none;
    cursor: pointer;
}

.button-discord:hover {
    background-color: #4752c4;
}

/* Mobile Adjustments */
@media (max-width: 640px) {
    .container {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    .nav-inner {
        flex-wrap: wrap;
        height: auto;
        padding: 0.75rem 0;
        gap: 0;
    }

    .nav-brand {
        order: 1;
        margin-right: auto;
    }

    .nav-actions {
        order: 2;
    }

    .nav-links {
        width: 100%;
        gap: 1rem;
        order: 3;
        overflow-x: auto;
        padding-bottom: 0.25rem;
        margin-top: 0.5rem;
        /* Force new line */
        mask-image: linear-gradient(to right, black 90%, transparent 100%);
        -webkit-mask-image: linear-gradient(to right, black 90%, transparent 100%);
    }

    .nav-user {
        margin-left: 0;
    }

    .header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .controls select {
        width: 100%;
    }

    .stats-row {
        gap: 1.5rem;
        justify-content: space-between;
    }
}

/* Summary Bar (Top Statistics) */
.stats-summary-bar {
    display: flex;
    justify-content: space-between;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 2rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.summary-item {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    flex: 1;
    text-align: center;
    border-right: 1px solid var(--border);
    transition: transform 0.2s;
}

.summary-item:last-child {
    border-right: none;
}

.summary-item:hover {
    transform: scale(1.05);
}

.summary-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--muted-foreground);
    font-weight: 500;
}

.summary-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--foreground);
    line-height: 1;
}

.summary-value.accent {
    color: #4a9eff;
    /* Blue accent */
}

@media (max-width: 768px) {
    .stats-summary-bar {
        flex-direction: column;
        gap: 1.5rem;
    }

    .summary-item {
        border-right: none;
        border-bottom: 1px solid var(--border);
        padding-bottom: 1rem;
    }

    .summary-item:last-child {
        border-bottom: none;
        padding-bottom: 0;
    }
}

/* Alert Messages - Toast Style (Global) */
.messages {
    position: fixed;
    top: 5rem;
    /* Below the nav */
    right: 1.5rem;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-width: 400px;
    pointer-events: none;
}

.alert {
    pointer-events: auto;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 500;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.4), 0 4px 6px -2px rgba(0, 0, 0, 0.2);
    animation: slideInToast 0.3s ease-out, fadeOutToast 0.4s ease-out 4.6s forwards;
    border-left: 4px solid;
    backdrop-filter: blur(12px);
    border: 1px solid var(--border);
}

.alert::before {
    font-size: 1.25rem;
    flex-shrink: 0;
}

/* Success Alert */
.alert-success {
    background: linear-gradient(135deg, rgba(34, 197, 94, 0.2), rgba(22, 163, 74, 0.15));
    color: #4ade80;
    border-left-color: #22c55e;
}

.alert-success::before {
    content: "✓";
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.5rem;
    height: 1.5rem;
    background: #22c55e;
    color: #000;
    border-radius: 50%;
    font-size: 0.875rem;
    font-weight: 700;
}

/* Warning Alert */
.alert-warning {
    background: linear-gradient(135deg, rgba(251, 191, 36, 0.2), rgba(245, 158, 11, 0.15));
    color: #fbbf24;
    border-left-color: #f59e0b;
}

.alert-warning::before {
    content: "⚠";
    color: #f59e0b;
}

/* Error Alert */
.alert-error {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.2), rgba(220, 38, 38, 0.15));
    color: #f87171;
    border-left-color: #ef4444;
}

.alert-error::before {
    content: "✕";
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.5rem;
    height: 1.5rem;
    background: #ef4444;
    color: #fff;
    border-radius: 50%;
    font-size: 0.875rem;
    font-weight: 700;
}

@keyframes slideInToast {
    from {
        opacity: 0;
        transform: translateX(100%);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes fadeOutToast {
    from {
        opacity: 1;
        transform: translateX(0);
    }

    to {
        opacity: 0;
        transform: translateX(100%);
    }
}

@media (max-width: 640px) {
    .messages {
        left: 1rem;
        right: 1rem;
        top: auto;
        bottom: 1rem;
        max-width: none;
    }
}

/* Inputs & Selects Global Styles */
.form-group input[type="number"],
.form-group input[type="text"],
.form-group input[type="date"],
.form-group input[type="email"],
.form-group input[type="password"],
.form-group textarea,
.form-group select {
    width: 100%;
    /* height: 2.75rem; Removed fixed height to allow textareas to size naturally */
    min-height: 2.75rem;
    padding: 0.625rem 1rem;
    border: 1px solid var(--border);
    background: var(--background);
    color: var(--foreground);
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-family: 'Outfit', sans-serif;
    transition: all 0.2s ease;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 1px var(--primary);
}

.form-group input:hover,
.form-group textarea:hover,
.form-group select:hover {
    border-color: var(--muted-foreground);
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    font-size: 0.925rem;
    color: var(--foreground);
}

.form-group small {
    display: block;
    margin-top: 0.5rem;
    color: var(--muted-foreground);
    font-size: 0.8rem;
}

.form-group {
    margin-bottom: 1.5rem;
}

/* Buttons Global Styles */
.btn {
    width: 100%;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    padding: 0.75rem 1.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: var(--radius);
    border: none;
    cursor: pointer;
    background-color: var(--primary);
    color: var(--primary-foreground);
    transition: opacity 0.2s;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.btn:hover {
    opacity: 0.9;
}

.btn-primary {
    background-color: var(--primary);
    color: var(--primary-foreground);
}

.btn-secondary {
    background-color: var(--secondary);
    color: var(--secondary-foreground);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background-color: var(--muted);
}

.btn-danger {
    background-color: var(--destructive);
    color: var(--destructive-foreground);
}

/* Icon Buttons */
.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    padding: 0;
    border-radius: var(--radius);
    color: var(--muted-foreground);
    background: transparent;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-icon:hover {
    color: var(--foreground);
    background-color: var(--secondary);
}

.btn-icon.text-danger:hover {
    color: var(--destructive);
    background-color: rgba(239, 68, 68, 0.1);
}