/* --- 1. Custom Variables & Dark Mode Colors --- */
:root {
    --color-primary: #135bec;
    --color-background-light: #f6f6f8;
    --color-background-dark: #101622;
    --color-gray-50: #f9fafb;
    --color-gray-200: #e5e7eb;
    --color-gray-300: #d1d5db;
    --color-gray-400: #9ca3af;
    --color-gray-600: #6b7280;
    --color-gray-700: #4b5563;
    --color-gray-800: #1f2937;
    --color-gray-900: #111827;
    --color-white: #ffffff;
    --color-black: #000000;
}

/* --- 2. Base Styles (Body & Layout) --- */
/* The .dark class will be applied to the html tag in the PHP template */
.dark {
    /* This ensures dark theme specific variables are used inside a dark context */
    --color-text-base: var(--color-gray-200);
    --color-bg-base: var(--color-background-dark);
}

body {
    background-color: rgb(16 22 34 / var(--tw-bg-opacity, 1));
    color: var(--color-gray-800);                   /* text-gray-800 */
    font-family: 'Inter', sans-serif;                /* font-display */
    margin: 0;
    padding: 0;
}

/* Override body colors for dark mode context */
.dark body {
    background-color: var(--color-background-dark); /* dark:bg-background-dark */
    color: var(--color-gray-200);                   /* dark:text-gray-200 */
}

/* Dashboard Layout (flex h-screen w-full) */
.dashboard-container {
    display: flex;
    height: 100vh; /* equivalent to h-screen */
    width: 100%;
}
.dashboard-main {
    flex: 1; /* equivalent to flex-1 */
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}
.content-padding {
    padding: 2rem; /* p-8 */
}
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.space-x-2 > * + * { margin-left: 0.5rem; } /* space-x-2 */
.space-x-6 > * + * { margin-left: 1.5rem; } /* space-x-6 */
.mb-6 { margin-bottom: 1.5rem; } /* mb-6 */
.mt-12 { margin-top: 3rem; } /* mt-12 */
.flex-wrap { flex-wrap: wrap; }
.gap-x-6 > * { margin-right: 1.5rem; } /* gap-x-6 */
.gap-y-2 > * { margin-bottom: 0.5rem; } /* gap-y-2 */

/* --- 3. Typography & Icons --- */
.text-2xl { font-size: 1.5rem; line-height: 2rem; }
.text-xl { font-size: 1.25rem; line-height: 1.75rem; }
.text-sm { font-size: 0.875rem; line-height: 1.25rem; }
.text-xs { font-size: 0.75rem; line-height: 1rem; }
.font-bold { font-weight: 700; }
.font-medium { font-weight: 500; }
.text-center { text-align: center; }

/* Text Color Overrides */
.text-gray-900 { color: white; }
.dark .text-white { color: var(--color-white); }
.text-gray-700 { color: var(--color-gray-700); }
.dark .text-gray-300 { color: var(--color-gray-300); }
.text-gray-600 { color: rgb(156 163 175 / var(--tw-text-opacity, 1)); }
.dark .text-gray-400 { color: var(--color-gray-400); }

.material-symbols-outlined {
    font-variation-settings:
    'FILL' 0,
    'wght' 400,
    'GRAD' 0,
    'opsz' 24;
    font-size: 1rem; /* text-base */
}

/* --- 4. Component: Buttons & Controls --- */
/* Base button styles for Yesterday/Today buttons (px-4 py-2 text-sm font-medium rounded-lg) */
.btn-control {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: 0.5rem;
    border: 1px solid;
    transition: background-color 0.2s;
}

/* Secondary Button (Yesterday) */
.btn-secondary {
    color: var(--color-gray-700);
    background-color: var(--color-white);
    border-color: var(--color-gray-300);
}
.dark .btn-secondary {
    background-color: rgba(0, 0, 0, 0.2); /* dark:bg-black/20 */
    border-color: rgba(255, 255, 255, 0.1); /* dark:border-white/10 */
    color: var(--color-gray-300);
}
.btn-secondary:hover {
    background-color: var(--color-gray-50); /* hover:bg-gray-50 */
}
.dark .btn-secondary:hover {
    background-color: rgba(0, 0, 0, 0.3); /* dark:hover:bg-black/30 */
}

/* Primary Button (Today/Submit Rewards) */
.btn-primary {
    color: var(--color-white);
    background-color: var(--color-primary);
    border-color: var(--color-primary);
}
.btn-primary:hover {
    background-color: #135becd9; /* hover:bg-primary/90 (90% opacity) */
}

/* Action Buttons (Table actions) */
.btn-action {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 2rem; /* h-8 */
    border-radius: 0.375rem; /* rounded-md */
    font-size: 0.75rem; /* text-xs */
    font-weight: 700; /* font-bold */
    transition: background-color 0.2s;
    line-height: 1; /* Helps with vertical alignment */
}

/* Action Button: Specific sizing for Check icon button (w-8 h-8) */
.btn-action.check {
    width: 2rem; /* w-8 */
    padding: 0; /* Remove horizontal padding */
}

/* Action Button: Specific padding for text buttons (px-3 h-8) */
.btn-action.text {
    padding: 0 0.75rem; /* px-3 */
}

/* Red (End Match) */
.btn-action.red {
    background-color: rgba(239, 68, 68, 0.1); /* bg-red-500/10 */
    color: #ef4444; /* text-red-500 */
}
.btn-action.red:hover {
    background-color: rgba(239, 68, 68, 0.2); /* hover:bg-red-500/20 */
}

/* Green (Start/Check) */
.btn-action.green {
    background-color: rgba(34, 197, 94, 0.1); /* bg-green-500/10 */
    color: #22c55e; /* text-green-500 */
}
.btn-action.green:hover {
    background-color: rgba(34, 197, 94, 0.2); /* hover:bg-green-500/20 */
}

/* Yellow (Reward Players) */
.btn-action.yellow {
    background-color: rgba(245, 158, 11, 0.1); /* bg-yellow-500/10 */
    color: #f59e0b; /* text-yellow-500 */
}
.btn-action.yellow:hover {
    background-color: rgba(245, 158, 11, 0.2); /* hover:bg-yellow-500/20 */
}

/* Gray (View Log / Disabled Check) */
.btn-action.gray {
    background-color: rgba(107, 114, 128, 0.1); /* bg-gray-500/10 */
    color: #6b7280; /* text-gray-500 */
}
.btn-action.gray:hover {
    background-color: rgba(107, 114, 128, 0.2); /* hover:bg-gray-500/20 */
}
.btn-action.disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

/* --- 5. Component: Table Styles --- */
.table-wrapper {
    overflow: hidden;
    border-radius: 0.75rem; /* rounded-xl */
    border: 1px solid rgba(255, 255, 255, 0.1); /* border-white/10 */
    background-color: rgba(255, 255, 255, 0.05); /* bg-white/5 */
    border-color: rgb(0 0 0 / 0.3);
}
.dark .table-wrapper {
    border: 1px solid rgba(0, 0, 0, 0.3); /* dark:border-black/30 */
    background-color: rgba(0, 0, 0, 0.2); /* dark:bg-black/20 */
}
.table-scroll {
    overflow-x: auto;
}
.data-table {
    min-width: 100%; /* min-w-full */
    text-align: left;
    border-collapse: collapse;
}

/* Table Head & Row Styles */
.data-table thead {
    background-color: rgb(0 0 0 / 0.2);
    border-color: rgb(0 0 0 / 0.3);
}
.dark .data-table thead {
    background-color: rgba(0, 0, 0, 0.2); /* dark:bg-black/20 */
}
.data-table th, .data-table td {
    padding: 1rem 1.5rem; /* px-6 py-4 */
    font-size: 0.875rem; /* text-sm */
    line-height: 1.25rem;
}
.data-table thead tr, .data-table tbody tr {
    border-bottom: 1px solid rgba(255, 255, 255, 0.1); /* border-b border-white/10 */
    background-color: rgb(0 0 0 / 0.2);
    border-color: rgb(0 0 0 / 0.3);
}
.dark .data-table thead tr, .data-table tbody tr {
    border-bottom: 1px solid rgba(0, 0, 0, 0.3); /* dark:border-b dark:border-black/30 */
}

/* --- 6. Component: Badges/Status Tags --- */
.badge {
    display: inline-flex;
    align-items: center;
    border-radius: 9999px; /* rounded-full */
    padding: 0.25rem 0.75rem; /* px-3 py-1 */
    font-size: 0.75rem; /* text-xs */
    font-weight: 500; /* font-medium */
}
.badge.ongoing {
    background-color: #dcfce7; /* green-100 */
    color: #047857; /* green-700 */
}
.dark .badge.ongoing {
    background-color: rgba(16, 185, 129, 0.5); /* dark:bg-green-900/50 */
    color: #6ee7b7; /* dark:text-green-300 */
}
.badge.upcoming {
    background-color: #dbeafe; /* blue-100 */
    color: #1d4ed8; /* blue-700 */
}
.dark .badge.upcoming {
    background-color: rgba(59, 130, 246, 0.5); /* dark:bg-blue-900/50 */
    color: #93c5fd; /* dark:text-blue-300 */
}
.badge.finished {
    background-color: var(--color-gray-200); /* gray-200 */
    color: var(--color-gray-600); /* gray-600 */
}
.dark .badge.finished {
    background-color: rgba(55, 65, 81, 0.5); /* dark:bg-gray-700/50 */
    color: var(--color-gray-300); /* dark:text-gray-300 */
}
.badge.canceled {
    background-color: #fee2e2; /* red-100 */
    color: #b91c1c; /* red-700 */
}
.dark .badge.canceled {
    background-color: rgba(239, 68, 68, 0.5); /* dark:bg-red-900/50 */
    color: #fca5a5; /* dark:text-red-300 */
}
.badge.coins {
    background-color: #fef9c3; /* yellow-100 */
    color: #92400e; /* yellow-800 */
}
.dark .badge.coins {
    background-color: rgba(250, 202, 24, 0.5); /* dark:bg-yellow-900/50 */
    color: #fcd34d; /* dark:text-yellow-300 */
}
.badge.card {
    background-color: #dbeafe; /* blue-100 */
    color: #1e40af; /* blue-800 */
}
.dark .badge.card {
    background-color: rgba(59, 130, 246, 0.5); /* dark:bg-blue-900/50 */
    color: #93c5fd; /* dark:text-blue-300 */
}
.badge.gems {
    background-color: #ede9fe; /* purple-100 */
    color: #6d28d9; /* purple-800 */
}
.dark .badge.gems {
    background-color: rgba(124, 58, 237, 0.5); /* dark:bg-purple-900/50 */
    color: #d8b4fe; /* dark:text-purple-300 */
}

/* --- 7. Component: Inputs & Forms (w-32 form-input p-1.5 text-sm) --- */
.input-room-id {
    width: 8rem; /* w-32 */
    background-color: transparent; /* bg-transparent */
    border: 1px solid var(--color-gray-300); /* border-gray-300 */
    border-radius: 0.375rem; /* rounded-md */
    padding: 0.375rem 0.5rem; /* p-1.5 */
    font-size: 0.875rem; /* text-sm */
    color: white; /* text-gray-800 */
    /* Focus styles */
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
    border-color: rgb(75 85 99 / var(--tw-border-opacity, 1));
    
}
.dark .input-room-id {
    border-color: var(--color-gray-600); /* dark:border-gray-600 */
    color: var(--color-gray-200); /* dark:text-gray-200 */
}
.input-room-id:focus {
    outline: none;
    border-color: var(--color-primary); /* focus:border-primary */
    box-shadow: 0 0 0 1px var(--color-primary); /* focus:ring-primary */
}

/* Radio Button Styles */
.reward-radio {
    display: flex;
    align-items: center;
    cursor: pointer;
}
.form-radio {
    /* Base Radio Styles (h-4 w-4) */
    appearance: none;
    -webkit-appearance: none;
    width: 1rem;
    height: 1rem;
    border-radius: 50%;
    border: 1px solid var(--color-gray-300); /* border-gray-300 */
    background-color: var(--color-gray-200); /* bg-gray-200 */
    cursor: pointer;
    transition: background-color 0.2s, border-color 0.2s;
    margin-right: 0.5rem; /* space-x-2 for the label text */
}

.dark .form-radio {
    border-color: var(--color-gray-600); /* dark:border-gray-600 */
    background-color: var(--color-gray-700); /* dark:bg-gray-700 */
}

/* Checked State Styles (Uses the original inline style logic) */
.form-radio:checked {
    background-image: url("data:image/svg+xml,%3csvg viewBox='0 0 16 16' fill='white' xmlns='http://www.w3.org/2000/svg'%3e%3ccircle cx='8' cy='8' r='3'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: center;
    background-size: 60%;
    border-color: var(--color-primary); /* border-primary */
    background-color: var(--color-primary); /* text-primary (color for the checkmark effect) */
}

/* Focus Ring Styles */
.form-radio:focus {
    /* The Tailwind ring focuses include a ring-offset. */
    outline: none;
    border-color: var(--color-primary); /* focus:border-primary */
    box-shadow: 0 0 0 4px var(--color-primary); /* focus:ring-primary (4px size) */
    /* This simulates the focus ring, the offset is tricky in pure CSS without a wrapper. */
}
/* Simulate dark:focus:ring-offset-background-dark by changing the focus shadow color */
.dark .form-radio:focus {
    box-shadow: 0 0 0 2px var(--color-background-dark), 0 0 0 4px var(--color-primary); 
    /* The 2px dark color simulates the ring-offset, which is necessary for dark mode clarity. */
}