:root {
    --primary-color: #4f46e5;
    --primary-color-hover: #4338ca;
    --sidebar-bg: #111827;
    --header-bg: #1f2937;
    --header-text-color: #f9fafb;
    --sidebar-text: rgba(255, 255, 255, 0.7);
    --sidebar-text-active: #ffffff;
    --sidebar-hover-bg: #374151;
    --bg-color: #f9fafb;
    --text-color: #1f2937;
    --card-bg: #ffffff;
    --card-border: #e5e7eb;
    --footer-bg: #ffffff;
    --footer-border: #e5e7eb;
}

body.dark-mode {
    --primary-color: #6366f1;
    --primary-color-hover: #818cf8;
    --sidebar-bg: #0f172a;
    --header-bg: #111827;
    --header-text-color: #f9fafb;
    --sidebar-text: rgba(255, 255, 255, 0.6);
    --sidebar-text-active: #ffffff;
    --sidebar-hover-bg: #334155;
    --bg-color: #111827;
    --text-color: #f9fafb;
    --card-bg: #1f2937;
    --card-border: #374151;
    --footer-bg: #1f2937;
    --footer-border: #374151;
}

@keyframes slideInFadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes pulse {
    0% { transform: scale(1); opacity: 0.8; }
    50% { transform: scale(1.05); opacity: 1; }
    100% { transform: scale(1); opacity: 0.8; }
}

/* --- Preloader Styles --- */
#preloader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: var(--bg-color);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.7s ease-in-out, visibility 0.7s ease-in-out;
    visibility: visible;
    opacity: 1;
}

#preloader.fade-out {
    opacity: 0;
    visibility: hidden;
}

.preloader-content h3 {
    font-weight: 700;
    font-size: 2.5rem;
    animation: pulse 2.5s infinite ease-in-out;
    color: var(--primary-color);
    text-align: center;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
    transition: background-color 0.3s, color 0.3s;
}

/* --- Layout & Structure --- */
#main-wrapper { min-width: 0; }
#main-content { background-color: var(--bg-color); animation: slideInFadeIn 0.5s ease-out; }
#main-header { background-color: var(--header-bg); color: var(--header-text-color); border-color: var(--header-footer-border) !important; transition: background-color 0.3s, border-color 0.3s; }
#main-footer { background-color: var(--footer-bg); border-color: var(--footer-border) !important; transition: background-color 0.3s, border-color 0.3s; }

/* --- Sidebar & Navigation --- */
#sidebar { background-color: var(--sidebar-bg) !important; transition: background-color 0.3s; border-right: 1px solid var(--header-footer-border); }
#sidebar .offcanvas-title { font-weight: 600; }
#sidebar .nav-link { color: var(--sidebar-text) !important; font-size: 1rem; padding: 0.75rem 1.5rem; border-radius: 0.375rem; transition: background-color 0.2s, color 0.2s; }
#sidebar .nav-link:hover { background-color: var(--sidebar-hover-bg); color: var(--sidebar-text-active) !important; }
#sidebar .nav-link.active { background-color: var(--primary-color); color: var(--sidebar-text-active) !important; }
#sidebar .nav-link i { margin-right: 0.75rem; }

/* --- Cards & Modals --- */
.card, .modal-content { background-color: var(--card-bg); border: 1px solid var(--card-border); border-radius: 0.75rem; color: var(--text-color); box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1); transition: background-color 0.3s, border-color 0.3s; }
.card-header { background-color: transparent; border-bottom: 1px solid var(--card-border); font-weight: 600; }

/* --- Forms & Buttons --- */
.btn { border-radius: 0.375rem; font-weight: 500; }
.btn-primary { background-color: var(--primary-color); border-color: var(--primary-color); transition: background-color 0.2s; }
.btn-primary:hover { background-color: var(--primary-color-hover); border-color: var(--primary-color-hover); }
.form-control, .form-select { background-color: var(--card-bg); color: var(--text-color); border-color: var(--card-border); border-radius: 0.375rem; }
.form-control:focus, .form-select:focus { background-color: var(--card-bg); color: var(--text-color); border-color: var(--primary-color); box-shadow: 0 0 0 0.25rem rgba(79, 70, 229, 0.25); }

/* --- Specific Fixes & Styles --- */
.coaching-name-header { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--header-text-color) !important; }
#theme-switcher { color: var(--header-text-color); }
#globalSearchInput::placeholder { color: #9ca3af; }
.chart-container { position: relative; height: 300px; width: 100%; max-width: 100%; }
.attendance-radio-group .form-check-input { display: none; }
.attendance-radio-group .form-check-label { padding: 0.375rem 0.75rem; border: 1px solid var(--card-border); border-radius: 0.25rem; cursor: pointer; transition: all 0.2s; }
.attendance-radio-group .form-check-input:checked + .form-check-label.label-present { background-color: #10b981; color: white; border-color: #10b981; }
.attendance-radio-group .form-check-input:checked + .form-check-label.label-absent { background-color: #ef4444; color: white; border-color: #ef4444; }
.forbit-link { background: linear-gradient(45deg, var(--primary-color), var(--primary-color-hover)); -webkit-background-clip: text; background-clip: text; color: transparent; font-weight: 600; text-decoration: none; }

/* --- Login Page Styles --- */
.login-page-body { display: flex; align-items: center; justify-content: center; height: 100vh; background: var(--bg-color); background: linear-gradient(45deg, var(--sidebar-bg), var(--bg-color)); }
.login-card { width: 100%; max-width: 420px; background-color: var(--card-bg) !important; }
.login-header { font-weight: 700; color: var(--primary-color); }

/* --- Mobile Responsiveness --- */
@media (min-width: 992px) {
    #sidebar { width: 280px; transform: none !important; visibility: visible !important; }
    #main-wrapper { margin-left: 280px; }
}

/* --- Profile Picture Placeholders & Images --- */
.profile-photo-placeholder {
    width: 80px; /* From student-profile.html */
    height: 80px;
    background-color: var(--sidebar-hover-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    overflow: hidden; /* Crucial for containing the image */
}
.profile-photo-placeholder img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.profile-pic-sm {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    overflow: hidden;
    display: inline-block;
    background-color: var(--card-border);
    vertical-align: middle;
}
.profile-pic-sm img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Old placeholder for empty state in list */
.profile-photo-placeholder-sm {
    width: 40px;
    height: 40px;
    background-color: var(--card-border);
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23868e96'%3e%3cpath d='M12 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm0 2c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4z'/%3e%3c/svg%3e");
    background-size: 70%;
    background-repeat: no-repeat;
    background-position: center;
    border-radius: 50%;
}

.bg-success-soft {
    background-color: rgba(22, 163, 74, 0.2);
    color: #16a34a;
}

.bg-danger-soft {
    background-color: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

/* Make profile images perfectly round */
.profile-photo-placeholder-sm .rounded-circle,
.profile-photo-placeholder .rounded-circle {
    width: 100%;
    height: 100%;
    object-fit: cover;
}