@tailwind base;
@tailwind components;
@tailwind utilities;

/* ===============================
   ROOT + BODY
================================ */
:root {
    --bg-primary: #f8fafc;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --brand-primary: #4f46e5;
    --brand-secondary: #ec4899;
    --brand-primary-light: #e0e7ff;
    --brand-secondary-light: #fce7f3;

    /* Card Colors (4 main colors for stat cards) */
    --card-blue: #3b82f6;
    --card-blue-light: #dbeafe;
    --card-green: #10b981;
    --card-green-light: #d1fae5;
    --card-orange: #f97316;
    --card-orange-light: #ffedd5;
    --card-pink: #ec4899;
    --card-pink-light: #fce7f3;

    /* Chart Color Palette */
    --chart-color-1: #3b82f6;
    --chart-color-2: #10b981;
    --chart-color-3: #f59e0b;
    --chart-color-4: #ef4444;
    --chart-color-5: #8b5cf6;
    --chart-color-6: #06b6d4;

    /* Premium Shadows */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
    --shadow-2xl: 0 25px 50px -12px rgb(0 0 0 / 0.1);
    --shadow-premium: 0 20px 40px -15px rgba(0, 0, 0, 0.1);
    --shadow-brand: 0 20px 25px -5px var(--brand-primary-light), 0 8px 10px -6px var(--brand-primary-light);
}

body {
    background-color: var(--bg-primary);
    background-image:
        radial-gradient(at 0% 0%, var(--brand-primary-light) 0px, transparent 50%),
        radial-gradient(at 100% 0%, var(--brand-secondary-light) 0px, transparent 50%);
    background-attachment: fixed;
    background-size: cover;
    font-family: 'Plus Jakarta Sans', sans-serif;
    color: var(--text-primary);
    letter-spacing: -0.01em;
    -webkit-font-smoothing: antialiased;
}

/* Global Page Transition */
.page-fade-in {
    animation: fadeIn 0.5s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ===============================
   COMPONENTS
================================ */
@layer components {

    .glass-panel {
        @apply bg-white/80 border border-white/50 backdrop-blur-xl rounded-3xl;
        box-shadow: 0 20px 40px -15px rgba(0, 0, 0, 0.1);
    }

    .glass-card {
        @apply border border-slate-200/60 backdrop-blur-sm shadow-sm hover:shadow-md transition-all duration-300 rounded-2xl;
        background: linear-gradient(to bottom, rgba(255, 255, 255, 0.7), rgba(248, 250, 252, 0.5));
    }

    /* Sidebar links */
    .sidebar-link {
        @apply flex items-center gap-3 px-4 py-2.5 text-slate-500 rounded-xl transition-all duration-300 relative overflow-hidden;
    }

    .sidebar-link:hover {
        color: var(--brand-primary);
        background-color: rgba(79, 70, 229, 0.08);
    }

    .sidebar-link.active {
        @apply bg-white font-black shadow-lg border border-slate-100;
        color: var(--brand-primary);
    }

    .sidebar-link.active::before {
        content: '';
        @apply absolute left-0 top-1/2 -translate-y-1/2 w-1 h-3/5 rounded-full;
        background-color: var(--brand-primary);
    }

    /* Buttons */
    .btn-primary {
        @apply px-6 py-3 rounded-xl font-black text-white transition-all duration-300 hover:shadow-lg active:scale-[0.98] border-0 text-sm tracking-tight;
        background: linear-gradient(to right, var(--brand-primary), var(--brand-secondary));
    }

    .btn-secondary {
        @apply px-6 py-3 rounded-xl font-black bg-white border border-slate-200 text-slate-600 transition-all duration-300 hover:bg-slate-50 hover:border-slate-300 active:scale-[0.98] text-sm tracking-tight;
    }

    .btn-danger {
        @apply px-6 py-3 rounded-xl font-black bg-rose-50 text-rose-600 transition-all duration-300 hover:bg-rose-100 active:scale-[0.98] text-sm tracking-tight;
    }

    .btn-icon-slate {
        @apply p-2 rounded-xl bg-slate-50 text-slate-400 hover:bg-slate-100 hover:text-slate-600 transition-all duration-300 active:scale-95;
    }

    .form-input {
        @apply w-full px-4 py-3 rounded-xl bg-white/50 border border-slate-200 text-slate-800 focus:outline-none focus:ring-4 transition-all;
    }

    .form-input:focus {
        border-color: var(--brand-primary);
        box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.05);
    }

    .stat-card-premium {
        @apply glass-panel p-6 relative overflow-hidden group hover:-translate-y-1 transition-all duration-500;
    }

    .stat-card-premium::after {
        content: '';
        @apply absolute top-0 right-0 w-24 h-24 bg-gradient-to-br from-brand-primary/5 to-transparent rounded-full -mr-12 -mt-12 transition-transform duration-700 group-hover:scale-150;
    }

    .table-container {
        @apply glass-panel overflow-hidden border border-slate-200 shadow-xl;
    }

    /* Colored Stat Cards */
    .stat-card-blue {
        @apply bg-gradient-to-br from-blue-500 to-blue-600 text-white p-6 rounded-2xl shadow-lg hover:shadow-xl transition-all duration-300 hover:-translate-y-1;
    }

    .stat-card-green {
        @apply bg-gradient-to-br from-emerald-500 to-green-600 text-white p-6 rounded-2xl shadow-lg hover:shadow-xl transition-all duration-300 hover:-translate-y-1;
    }

    .stat-card-orange {
        @apply bg-gradient-to-br from-orange-500 to-orange-600 text-white p-6 rounded-2xl shadow-lg hover:shadow-xl transition-all duration-300 hover:-translate-y-1;
    }

    .stat-card-pink {
        @apply bg-gradient-to-br from-pink-500 to-rose-600 text-white p-6 rounded-2xl shadow-lg hover:shadow-xl transition-all duration-300 hover:-translate-y-1;
    }

    .sidebar-label {
        @apply text-slate-400 font-black tracking-wider;
    }

    /* Modern Table Styles */
    .modern-table {
        @apply w-full;
    }

    .modern-table thead {
        @apply bg-slate-50 border-b border-slate-200;
    }

    .modern-table th {
        @apply px-6 py-4 text-left text-xs font-black text-slate-600 uppercase tracking-wider;
    }

    .modern-table td {
        @apply px-6 py-4 text-sm text-slate-700;
    }

    .modern-table tbody tr {
        @apply border-b border-slate-100 hover:bg-slate-50 transition-colors duration-150;
    }

    .modern-table tbody tr:last-child {
        @apply border-b-0;
    }

    /* Badge Variants */
    .badge {
        @apply inline-flex items-center px-3 py-1 rounded-full text-xs font-bold;
    }

    .badge-success {
        @apply bg-green-100 text-green-700;
    }

    .badge-warning {
        @apply bg-orange-100 text-orange-700;
    }

    .badge-danger {
        @apply bg-red-100 text-red-700;
    }

    .badge-info {
        @apply bg-blue-100 text-blue-700;
    }

    .badge-purple {
        @apply bg-purple-100 text-purple-700;
    }

    /* Progress Bars */
    .progress-bar {
        @apply w-full bg-slate-200 rounded-full h-2 overflow-hidden;
    }

    .progress-bar-fill {
        @apply h-full rounded-full transition-all duration-500;
    }

    .progress-bar-blue .progress-bar-fill {
        @apply bg-gradient-to-r from-blue-500 to-blue-600;
    }

    .progress-bar-green .progress-bar-fill {
        @apply bg-gradient-to-r from-green-500 to-emerald-600;
    }

    .progress-bar-orange .progress-bar-fill {
        @apply bg-gradient-to-r from-orange-500 to-orange-600;
    }

    .progress-bar-pink .progress-bar-fill {
        @apply bg-gradient-to-r from-pink-500 to-rose-600;
    }
}

/* ===============================
   SIDEBAR – DESKTOP
================================ */
@media (min-width: 768px) {
    #sidebar {
        position: static;
        width: 18rem;
        margin: 1rem;
        transform: translateX(0);
        display: flex;
        opacity: 1;
        visibility: visible;
    }

    #sidebar-overlay {
        display: none;
    }
}

/* ===============================
   SIDEBAR – MOBILE
================================ */
@media (max-width: 767px) {
    #sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: 280px;
        margin: 0;
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        z-index: 60;
    }

    #sidebar.mobile-open {
        transform: translateX(0);
        box-shadow: 0 25px 50px -12px rgba(0, 0, 0, .5);
    }

    #sidebar-overlay {
        position: fixed;
        inset: 0;
        background: rgba(15, 23, 42, .6);
        backdrop-filter: blur(4px);
        z-index: 50;
        display: none;
    }

    #sidebar-overlay.show {
        display: block;
    }

    .btn-primary,
    .btn-secondary,
    .btn-danger {
        padding: .5rem 1rem;
        font-size: .875rem;
        border-radius: .75rem;
    }
}

/* ===============================
   SIDEBAR COLLAPSE (DESKTOP)
================================ */
.sidebar-collapsed #sidebar {
    width: 5rem !important;
}

.sidebar-collapsed .sidebar-label,
.sidebar-collapsed .user-info {
    display: none !important;
}

.sidebar-collapsed .sidebar-link {
    justify-content: center !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
}

/* ===============================
   UTILITIES
================================ */
@layer utilities {
    .text-balance {
        text-wrap: balance;
    }
}

/* ===============================
   SCROLLBAR
================================ */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #e2e8f0;
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: #cbd5e1;
}