/* ========================================
   Reusable Components - Student Attendance System
   ======================================== */

/* Minimal Header Component (for profile dropdown only) */
.header-minimal {
    background: transparent;
    padding: 12px 24px;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-right {
    display: flex;
    align-items: center;
    gap: var(--spacing-lg);
    flex: 0 0 auto;
    order: 4;
    position: relative;
}

.user-profile-dropdown {
    position: relative;
}

.user-avatar-btn {
    cursor: pointer;
    transition: opacity 0.2s;
}

.user-avatar-btn:hover {
    opacity: 0.85;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: var(--primary-color);
    color: var(--white);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 16px;
}

.profile-dropdown-menu {
    position: fixed;
    top: 60px;
    right: 20px;
    background: var(--white);
    border-radius: var(--radius-md);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    min-width: 220px;
    display: none;
    z-index: 1000;
}

.profile-dropdown-menu.show {
    display: block;
}

.profile-dropdown-header {
    padding: 15px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.profile-dropdown-header .user-avatar {
    width: 45px;
    height: 45px;
    font-size: 18px;
}

.profile-name {
    font-weight: 600;
    color: #1f2937;
    font-size: 14px;
}

.profile-dropdown-divider {
    height: 1px;
    background-color: #e5e7eb;
    margin: 0;
}

.profile-dropdown-item {
    width: 100%;
    padding: 12px 15px;
    border: none;
    background: none;
    text-align: left;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    color: #1f2937;
    font-size: 14px;
    font-weight: 500;
    transition: background-color 0.2s;
}

.profile-dropdown-item:hover {
    background-color: #f3f4f6;
}

.profile-dropdown-item svg {
    color: #6b7280;
}

/* Responsive Header Minimal */
@media (max-width: 768px) {
    .header-minimal {
        display: none;
    }
}

/* Navigation Component */
.nav-tabs {
    background-color: var(--white);
    border-bottom: 2px solid var(--border-color);
    padding: 0 var(--spacing-3xl);
    display: flex;
    gap: var(--spacing-lg);
}

.nav-tab {
    padding: var(--spacing-md) var(--spacing-lg);
    color: var(--text-medium);
    text-decoration: none;
    border-bottom: 3px solid transparent;
    transition: all var(--transition-fast);
    font-weight: 500;
}

.nav-tab:hover {
    color: var(--text-dark);
    text-decoration: none;
}

.nav-tab.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

/* Statistics Card */
.stats-grid {
    display: flex;
    gap: 20px;
    margin-bottom: var(--spacing-3xl);
    justify-content: center;
    flex-wrap: wrap;
    max-width: 1100px;
    margin-left: auto;
    margin-right: auto;
}

.stat-card {
    background-color: var(--white);
    padding: 20px 20px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    transition: transform var(--transition-normal);
    width: 220px;
    flex-shrink: 0;
}

.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
}

.stat-card h3 {
    color: var(--text-medium);
    font-size: 12px;
    font-weight: 700;
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-card .number {
    color: var(--text-dark);
    font-size: 32px;
    font-weight: 800;
    margin-bottom: 5px;
    line-height: 1;
    min-height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Loading spinner for stats */
.loading-spinner {
    border: 3px solid rgba(0, 0, 0, 0.1);
    border-top: 3px solid var(--primary-color);
    border-radius: 50%;
    width: 24px;
    height: 24px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

.stat-card .label {
    color: var(--text-light);
    font-size: 12px;
    font-weight: 500;
}

.stat-card.red .number {
    color: var(--primary-color);
}

.stat-card.gray .number {
    color: var(--secondary-color);
}

.stat-card.green .number {
    color: var(--success-color);
}

/* Action Cards */
.actions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 180px));
    gap: 15px;
    justify-content: center;
    max-width: 1100px;
    margin: 0 auto;
}

.action-card {
    background-color: var(--white);
    padding: 18px 15px;
    border-radius: var(--radius-lg);
    text-align: center;
    cursor: pointer;
    transition: all var(--transition-normal);
    border: 2px solid var(--border-color);
    box-shadow: var(--shadow-md);
}

.action-card:hover {
    background-color: var(--secondary-color);
    color: var(--white);
    transform: translateY(-3px);
    border-color: var(--secondary-color);
}

.action-card.primary:hover {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

.action-card svg {
    width: 32px;
    height: 32px;
    margin-bottom: 10px;
    fill: var(--secondary-color);
    transition: fill var(--transition-normal);
}

.action-card:hover svg {
    fill: var(--white);
}

.action-card h3 {
    font-size: 14px;
    font-weight: 700;
    margin-bottom: 5px;
}

.action-card p {
    font-size: 11px;
    color: var(--text-medium);
    margin: 0;
    line-height: 1.3;
}

.action-card:hover p {
    color: var(--white);
}

/* Table Component */
.table-container {
    background-color: var(--white);
    border-radius: var(--radius-lg);
    overflow-x: auto;
    box-shadow: var(--shadow-md);
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th {
    background-color: var(--secondary-color);
    color: var(--white);
    padding: var(--spacing-md) var(--spacing-sm);
    text-align: left;
    font-size: 14px;
    font-weight: 600;
    border: none;
}

.table td {
    padding: var(--spacing-md) var(--spacing-sm);
    border-bottom: 1px solid var(--border-color);
    font-size: 14px;
    color: var(--text-dark);
}

.table tbody tr:hover {
    background-color: #f9f9f9;
}

.table tbody tr:last-child td {
    border-bottom: none;
}

/* Form Section Component */
.form-section {
    background-color: var(--white);
    padding: var(--spacing-xl) var(--spacing-3xl);
    border-radius: var(--radius-lg);
    margin-bottom: var(--spacing-lg);
    box-shadow: var(--shadow-md);
}

.form-grid {
    display: grid;
    grid-template-columns: auto 1fr auto 1fr auto 1fr;
    gap: var(--spacing-lg);
    align-items: center;
}

.form-grid label {
    font-weight: 600;
    color: var(--text-dark);
    white-space: nowrap;
}

/* Checkbox Group */
.checkbox-group {
    display: flex;
    gap: var(--spacing-md);
    align-items: center;
    flex-wrap: wrap;
}

.checkbox-group label {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    font-weight: normal;
    cursor: pointer;
}

/* Loading Spinner */
.spinner {
    border: 3px solid var(--border-color);
    border-top: 3px solid var(--primary-color);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: var(--spacing-lg) auto;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* Modal Component */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: var(--white);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
}

.modal-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.modal-body {
    padding: 14px 16px;
    overflow-y: auto;
    flex: 1 1 auto;
}

.modal-footer {
    padding: 12px 16px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    flex-shrink: 0;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-medium);
    transition: color 0.2s;
}

.modal-close:hover {
    color: var(--error-color);
}

/* Close button (X icon) in modal header */
.modal-header .close {
    background: none;
    border: none;
    font-size: 36px;
    cursor: pointer;
    color: var(--text-medium);
    transition: all 0.2s;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    line-height: 1;
    padding: 0;
    font-weight: 300;
}

.modal-header .close:hover {
    color: var(--primary-color);
    background: #f0f0f0;
}

/* Badge Component */
.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.badge-primary {
    background-color: var(--primary-color);
    color: var(--white);
}

.badge-secondary {
    background-color: var(--secondary-color);
    color: var(--white);
}

.badge-success {
    background-color: var(--success-color);
    color: var(--white);
}

/* Responsive Design */
@media (max-width: 768px) {
    .form-grid {
        grid-template-columns: 1fr;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .actions-grid {
        grid-template-columns: 1fr;
    }

    .nav-tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
}