/* --- Global Styles & Variables --- */
:root {
    --background-color: #F0F2F7;
    --primary-color: #6A86C5;
    --accent-color: #A0775B;
    --text-color: #333;
    --card-background: #FFFFFF;
    --border-color: #E5E7EB;
    --sidebar-bg: #FFFFFF;
    --sidebar-text: #374151;
    --sidebar-active-bg: #F0F2F7;
    --sidebar-active-text: #6A86C5;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--background-color);
    margin: 0;
    color: var(--text-color);
}

/* --- Login Page Styles --- */
.login-body {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}

.login-container {
    background-color: var(--card-background);
    padding: 40px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: 400px;
    box-sizing: border-box;
}

.login-container h2 {
    text-align: center;
    color: var(--primary-color);
    margin-top: 0;
    margin-bottom: 30px;
    font-size: 24px;
}

.login-container .error {
    background-color: #ffdddd;
    color: #d8000c;
    border: 1px solid #d8000c;
    padding: 10px;
    border-radius: 4px;
    text-align: center;
    margin-bottom: 20px;
}

.input-group {
    margin-bottom: 20px;
}

.input-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    font-size: 14px;
}

.input-group input,
.input-group select,
textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    box-sizing: border-box;
    font-size: 16px;
    font-family: 'Inter', sans-serif;
    transition: border-color 0.3s;
}

.input-group input:focus,
.input-group select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(106, 134, 197, 0.2);
}

button, .btn {
    width: 100%;
    padding: 12px;
    background-color: var(--primary-color);
    border: none;
    color: white;
    font-size: 16px;
    font-weight: 600;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.3s;
    text-decoration: none;
    display: inline-block;
    text-align: center;
}

button:hover, .btn:hover {
    background-color: #5875b3;
}

/* --- App Layout --- */
.app-container {
    display: flex;
}

.sidebar {
    width: 240px;
    background: var(--sidebar-bg);
    min-height: 100vh;
    box-shadow: 2px 0 5px rgba(0,0,0,0.05);
}

.sidebar-header {
    padding: 20px;
    text-align: center;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-header h2 {
    margin: 0;
    color: var(--primary-color);
}

.sidebar ul {
    list-style: none;
    padding: 20px 0;
    margin: 0;
}

.sidebar ul li a {
    display: block;
    padding: 15px 20px;
    color: var(--sidebar-text);
    text-decoration: none;
    font-weight: 600;
    transition: all 0.2s ease-in-out;
}

.sidebar ul li a:hover {
    background-color: var(--sidebar-active-bg);
    color: var(--sidebar-active-text);
}

.main-content {
    flex-grow: 1;
    padding: 40px;
    overflow-y: auto;
}

.header {
    margin-bottom: 30px;
}

.header h1 {
    margin: 0 0 5px 0;
    font-size: 32px;
}

.header p {
    margin: 0;
    color: #6B7280;
}

/* --- Components --- */
.card {
    background: var(--card-background);
    border-radius: 8px;
    padding: 24px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    margin-bottom: 24px;
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 24px;
}

.card h3 {
    margin-top: 0;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
}

table th, table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

table th {
    background-color: #F9FAFB;
    font-weight: 600;
}

.success {
    background-color: #d4edda;
    color: #155724;
    padding: 10px;
    border: 1px solid #c3e6cb;
    border-radius: 4px;
    margin-bottom: 20px;
}

/* --- Mobile Responsive --- */
@media (max-width: 768px) {
    .app-container {
        flex-direction: column;
    }
    .sidebar {
        width: 100%;
        min-height: auto;
        display: flex;
        flex-direction: column;
    }
    .main-content {
        padding: 20px;
    }
    .header h1 {
        font-size: 24px;
    }
    .login-container {
        padding: 20px;
    }
}

/* --- Admin/Students Page Enhancements --- */
.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.search-box {
    width: 300px;
}

.pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 20px;
}

.pagination-links a, .pagination-links strong {
    margin: 0 5px;
    padding: 8px 12px;
    text-decoration: none;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--primary-color);
}

.pagination-links a:hover {
    background-color: var(--sidebar-active-bg);
}

.pagination-links strong {
    background-color: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.btn-view {
    background-color: #17a2b8 !important;
    padding: 8px 12px;
    font-size: 14px;
    width: auto;
}
.btn-edit {
    background-color: #ffc107 !important;
    padding: 8px 12px;
    font-size: 14px;
    width: auto;
}
.btn-reset-pass {
    background-color: #6c757d !important;
    padding: 8px 12px;
    font-size: 14px;
    width: auto;
}

.profile-view-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.profile-view-grid p {
    margin: 0;
    padding: 8px 0;
}

.profile-view-grid strong {
    display: block;
    color: #6B7280;
    font-size: 14px;
}

/* --- Metrics History Table Enhancements --- */
.card-header-action {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.badge {
    display: inline-block;
    padding: .25em .6em;
    font-size: 75%;
    font-weight: 700;
    line-height: 1;
    text-align: center;
    white-space: nowrap;
    vertical-align: baseline;
    border-radius: .25rem;
}

.badge-in-use {
    color: #fff;
    background-color: #28a745;
}

.actions-cell {
    display: flex;
    gap: 10px;
}

.actions-cell .btn, .actions-cell form {
    margin: 0;
}

.btn-set-current {
    background-color: #ffc107 !important;
    padding: 5px 10px;
    font-size: 12px;
    width: auto;
}

/* --- Modal Styles --- */
.modal {
    display: none; 
    position: fixed; 
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%; 
    height: 100%; 
    overflow: auto; 
    background-color: rgba(0,0,0,0.4); 
}

.modal-content {
    background-color: #fefefe;
    margin: 15% auto; 
    padding: 20px;
    border: 1px solid #888;
    width: 80%;
    max-width: 500px;
    border-radius: 8px;
    position: relative;
}

.close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    position: absolute;
    top: 10px;
    right: 20px;
}

.close:hover,
.close:focus {
    color: black;
    text-decoration: none;
    cursor: pointer;
}

/* --- Message Styles --- */
.success {
    background-color: #d4edda;
    color: #155724;
    padding: 15px;
    border: 1px solid #c3e6cb;
    border-radius: 4px;
    margin-bottom: 20px;
}

.error {
    background-color: #f8d7da;
    color: #721c24;
    padding: 15px;
    border: 1px solid #f5c6cb;
    border-radius: 4px;
    margin-bottom: 20px;
}

/* --- Enrollment Modal Enhancements --- */
.modal-content h3 {
    margin-top: 0;
    color: var(--primary-color);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
}

.modal-footer .btn {
    width: auto;
}

.draw-animation {
    text-align: center;
    padding: 40px 20px;
}

.draw-animation .spinner {
    border: 8px solid #f3f3f3;
    border-top: 8px solid var(--primary-color);
    border-radius: 50%;
    width: 60px;
    height: 60px;
    animation: spin 1.5s linear infinite;
    margin: 0 auto 20px auto;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.character-result {
    text-align: center;
}

.character-result img {
    max-width: 250px;
    border-radius: 8px;
    margin: 15px auto;
    border: 2px solid var(--border-color);
}

.character-result blockquote {
    font-style: italic;
    color: #555;
    margin: 10px 0;
    padding: 10px;
    background: #f9f9f9;
    border-left: 5px solid var(--border-color);
}

/* --- Character Reveal Animation --- */
.reveal-container {
    text-align: center;
    padding: 20px;
    border: 2px dashed var(--border-color);
    border-radius: 8px;
}

.reveal-scroller {
    height: 150px;
    width: 150px;
    margin: 20px auto;
    border: 3px solid var(--primary-color);
    border-radius: 8px;
    overflow: hidden;
    position: relative;
    background-color: #e9e9e9;
}

.reveal-scroller .scroller-inner {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    animation: slot-spin 1.5s ease-out forwards;
}

.reveal-scroller img {
    width: 150px;
    height: 150px;
    object-fit: cover;
}

.reveal-final-result {
    display: none; /* Hidden by default, shown with JS */
}

@keyframes slot-spin {
  0% { transform: translateY(-80%); }
  80% { transform: translateY(0%); }
  90% { transform: translateY(-5%); }
  100% { transform: translateY(0%); }
}

/* --- Table Action Button Alignment Fix --- */
.actions-cell {
    display: flex;
    align-items: center; /* This vertically aligns the items */
    gap: 8px; /* This adds a small space between buttons */
}
.actions-cell .btn, .actions-cell button {
    margin: 0; /* Resets any default margins */
}

/* --- Table Action Button Alignment Fix --- */
.actions-cell {
    display: flex;
    align-items: center; /* This vertically aligns the items */
    gap: 8px; /* This adds a small space between buttons */
}

/* This is the new rule that fixes the height */
.actions-cell .btn, .actions-cell button {
    padding: 8px 12px;
    font-size: 14px;
    width: auto;
    white-space: nowrap; /* Prevents text from wrapping */
    margin: 0;
}

/* --- Tag Styles --- */
.tag-container {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding-top: 5px;
    margin-bottom: 15px; /* Add some space below the tags */
}

.tag {
    display: inline-block;
    background-color: #e5e7eb; /* A light gray background */
    color: #4b5563; /* A darker gray text */
    padding: 4px 10px;
    border-radius: 9999px; /* This creates the pill shape */
    font-size: 12px;
    font-weight: 600;
}

/* --- Code Label Print Styles --- */
.label-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    padding-top: 20px;
}

.code-label {
    width: 60mm;
    height: 40mm;
    border: 1px dashed #999;
    padding: 5mm;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    overflow: hidden;
}

.label-event-name {
    font-size: 12px;
    font-weight: bold;
}

.label-code {
    font-size: 24px;
    font-weight: bold;
    color: var(--primary-color);
    margin: 10px 0;
    letter-spacing: 2px;
}

.label-points {
    font-size: 14px;
}

/* Print-specific styles */
@media print {
    body {
        background-color: #fff;
    }
    .sidebar, .header, .card:first-child, .print-button {
        display: none !important;
    }
    .main-content {
        padding: 0;
    }
    .card {
        box-shadow: none;
        border: none;
        padding: 0;
    }
    .code-label {
        border: 1px solid #000; /* Use solid border for printing */
        page-break-inside: avoid; /* Try to prevent labels from splitting across pages */
    }
}

/* --- Tag Styles --- */
.tag-container {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding-top: 5px;
    margin-bottom: 15px; /* Add some space below the tags */
}

.tag {
    display: inline-block;
    background-color: #e5e7eb; /* A light gray background */
    color: #4b5563; /* A darker gray text */
    padding: 4px 10px;
    border-radius: 9999px; /* This creates the pill shape */
    font-size: 12px;
    font-weight: 600;
}