* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'SF Pro Text', 'Helvetica Neue', Helvetica, Arial, sans-serif;
    background-color: #F2F2F7;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Login Page */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}

.login-card {
    background: #FFFFFF;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
    padding: 40px;
    width: 100%;
    max-width: 400px;
}

.login-header {
    text-align: center;
    margin-bottom: 32px;
}

.login-logo {
    width: 80px;
    height: 80px;
    object-fit: contain;
    margin-bottom: 16px;
}

.login-header h1 {
    color: #000000;
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.5px;
    margin-bottom: 8px;
}

.login-header p {
    color: #8E8E93;
    font-size: 15px;
}

.login-form .form-group {
    margin-bottom: 20px;
}

.login-form label {
    display: block;
    font-weight: 600;
    color: #000000;
    margin-bottom: 8px;
    font-size: 15px;
}

.login-form input {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid #C6C6C8;
    border-radius: 10px;
    font-size: 17px;
    font-family: inherit;
    background-color: #FFFFFF;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.login-form input:focus {
    outline: none;
    border-color: #007AFF;
    box-shadow: 0 0 0 4px rgba(0, 122, 255, 0.15);
}

.error-message {
    background: #FFF2F2;
    color: #FF3B30;
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 15px;
    text-align: center;
}

.btn-login {
    width: 100%;
    padding: 14px;
    background: #007AFF;
    color: #FFFFFF;
    border: none;
    border-radius: 10px;
    font-size: 17px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s ease;
    min-height: 44px;
    position: relative;
}

.btn-login:hover {
    background: #0051D5;
}

.btn-login:active {
    transform: scale(0.98);
    opacity: 0.8;
}

.btn-login:disabled {
    background: #C6C6C8;
    cursor: not-allowed;
}

.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: #FFFFFF;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.login-footer {
    text-align: center;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 0.5px solid #C6C6C8;
}

.login-footer a {
    color: #007AFF;
    text-decoration: none;
    font-size: 15px;
    font-weight: 500;
}

.login-footer a:hover {
    text-decoration: underline;
}

/* Admin Dashboard */
.admin-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

.admin-header {
    background: #FFFFFF;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 24px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.header-logo {
    width: 50px;
    height: 50px;
    object-fit: contain;
}

.header-left h1 {
    color: #000000;
    font-size: 24px;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.admin-email {
    color: #8E8E93;
    font-size: 15px;
}

.btn-logout {
    padding: 10px 20px;
    background: #F2F2F7;
    color: #007AFF;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-logout:hover {
    background: #E5E5EA;
}

/* Dashboard Statistics */
.dashboard-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: #FFFFFF;
    border-radius: 12px;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
    transition: transform 0.2s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
}

.stat-icon {
    font-size: 40px;
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
}

.stat-icon-blue {
    background: rgba(0, 122, 255, 0.1);
    color: #007AFF;
}

.stat-icon-green {
    background: rgba(52, 199, 89, 0.1);
    color: #34C759;
}

.stat-icon-orange {
    background: rgba(255, 149, 0, 0.1);
    color: #FF9500;
}

.stat-icon-purple {
    background: rgba(175, 82, 222, 0.1);
    color: #AF52DE;
}

.stat-content {
    flex: 1;
}

.stat-value {
    font-size: 32px;
    font-weight: 700;
    color: #000000;
    letter-spacing: -0.5px;
    margin-bottom: 4px;
}

.stat-label {
    font-size: 15px;
    color: #8E8E93;
    font-weight: 500;
}

/* Controls Section */
.controls-section {
    background: #FFFFFF;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 24px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
}

.filters {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
    align-items: center;
}

.search-wrapper,
.filter-wrapper,
.date-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.search-wrapper svg,
.filter-wrapper svg,
.date-wrapper svg {
    position: absolute;
    left: 12px;
    color: #8E8E93;
    pointer-events: none;
}

.search-wrapper input {
    padding-left: 40px;
}

.filter-wrapper select,
.date-wrapper input {
    padding-left: 38px;
}

.search-input {
    flex: 1;
    min-width: 250px;
    padding: 12px 16px;
    border: 1px solid #C6C6C8;
    border-radius: 10px;
    font-size: 17px;
    font-family: inherit;
}

.filter-select,
.filter-input {
    padding: 12px 16px;
    border: 1px solid #C6C6C8;
    border-radius: 10px;
    font-size: 17px;
    font-family: inherit;
    background: #FFFFFF;
}

.actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.btn-primary {
    padding: 12px 24px;
    background: #007AFF;
    color: #FFFFFF;
    border: none;
    border-radius: 10px;
    font-size: 17px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-primary:hover {
    background: #0051D5;
}

.btn-secondary {
    padding: 12px 24px;
    background: #F2F2F7;
    color: #007AFF;
    border: none;
    border-radius: 10px;
    font-size: 17px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-secondary:hover {
    background: #E5E5EA;
}

.btn-danger {
    padding: 12px 24px;
    background: #FF3B30;
    color: #FFFFFF;
    border: none;
    border-radius: 10px;
    font-size: 17px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-danger:hover {
    background: #D32F2F;
}

/* Table */
.table-container {
    background: #FFFFFF;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
    margin-bottom: 24px;
}

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

.data-table thead {
    background: #F2F2F7;
}

.data-table th {
    padding: 16px;
    text-align: left;
    font-weight: 600;
    color: #000000;
    font-size: 15px;
    border-bottom: 0.5px solid #C6C6C8;
    cursor: pointer;
    user-select: none;
}

.th-content {
    display: flex;
    align-items: center;
    gap: 8px;
}

.th-content svg:first-child {
    opacity: 0.6;
}

.sort-icon {
    opacity: 0.4;
    transition: opacity 0.2s ease;
}

.data-table th.sortable:hover .sort-icon {
    opacity: 1;
}

.data-table th.sortable:hover {
    background: #E5E5EA;
}

.data-table td {
    padding: 16px;
    border-bottom: 0.5px solid #C6C6C8;
    color: #3A3A3C;
    font-size: 15px;
}

/* Table Photo Thumbnail */
.table-name-cell {
    display: flex;
    align-items: center;
    gap: 12px;
}

.table-photo {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    object-fit: cover;
    border: 2px solid #E5E5EA;
    flex-shrink: 0;
}

.data-table tbody tr:hover {
    background: #F8F8F8;
}

.loading-cell,
.empty-cell,
.error-cell {
    text-align: center;
    padding: 40px;
    color: #8E8E93;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.loading-spinner {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

.error-cell {
    color: #FF3B30;
}

.btn-view {
    padding: 8px 16px;
    background: #007AFF;
    color: #FFFFFF;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-view:hover {
    background: #0051D5;
}

.btn-delete {
    padding: 8px 16px;
    background: #FF3B30;
    color: #FFFFFF;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-delete:hover {
    background: #D32F2F;
}

.action-buttons {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin-top: 24px;
}

.page-btn {
    padding: 10px 16px;
    background: #FFFFFF;
    border: 1px solid #C6C6C8;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 44px;
    min-height: 44px;
}

.page-btn:hover:not(:disabled) {
    background: #F2F2F7;
}

.page-btn.active {
    background: #007AFF;
    color: #FFFFFF;
    border-color: #007AFF;
}

.page-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.page-ellipsis {
    color: #8E8E93;
    padding: 0 8px;
}

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

.modal.show {
    display: flex;
}

.modal-content {
    background: #FFFFFF;
    border-radius: 12px;
    max-width: 900px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.modal-header {
    padding: 20px;
    border-bottom: 0.5px solid #C6C6C8;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    color: #000000;
    font-size: 22px;
    font-weight: 700;
}

.btn-close {
    background: none;
    border: none;
    font-size: 28px;
    color: #8E8E93;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.btn-close:hover {
    color: #000000;
    background: #F2F2F7;
}

.modal-body {
    padding: 20px;
}

.detail-section {
    margin-bottom: 24px;
}

.detail-section h3 {
    color: #007AFF;
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 0.5px solid #C6C6C8;
}

/* Student Photo Display in Admin */
.detail-photo-section {
    text-align: center;
    padding: 20px;
    background: linear-gradient(135deg, #F5F7FF 0%, #F8F9FA 100%);
    border-radius: 12px;
    border: 1px solid #E5E5EA;
}

.detail-photo-section h3 {
    border-bottom: none;
    margin-bottom: 16px;
}

.detail-photo-container {
    width: 200px;
    height: 200px;
    margin: 0 auto 16px;
    border-radius: 16px;
    overflow: hidden;
    background: #FFFFFF;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    border: 3px solid #FFFFFF;
}

.detail-photo {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.detail-student-name {
    color: #007AFF;
    font-size: 20px;
    font-weight: 700;
    margin-top: 12px;
    letter-spacing: -0.3px;
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 16px;
}

.detail-item label {
    display: block;
    font-size: 13px;
    color: #8E8E93;
    font-weight: 600;
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.detail-item p {
    font-size: 17px;
    color: #000000;
    font-weight: 500;
}

.detail-item.full-width {
    grid-column: 1 / -1;
}

.modal-footer {
    padding: 20px;
    border-top: 0.5px solid #C6C6C8;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* Responsive Design */
@media (max-width: 768px) {
    .admin-container {
        padding: 10px;
    }
    
    .header-content {
        flex-direction: column;
        gap: 16px;
    }
    
    .dashboard-stats {
        grid-template-columns: 1fr;
    }
    
    .filters {
        flex-direction: column;
    }
    
    .search-input {
        min-width: 100%;
    }
    
    .table-container {
        overflow-x: auto;
    }
    
    .data-table {
        min-width: 800px;
    }
    
    .modal-content {
        max-height: 95vh;
    }
    
    .detail-grid {
        grid-template-columns: 1fr;
    }
    
    .detail-photo-container {
        width: 150px;
        height: 150px;
    }
    
    .detail-student-name {
        font-size: 18px;
    }
    
    .table-name-cell {
        gap: 8px;
    }
    
    .table-photo {
        width: 35px;
        height: 35px;
    }
}

/* Navigation Tabs */
.nav-tabs {
    display: flex;
    background: white;
    border-radius: 12px;
    padding: 8px;
    margin-bottom: 24px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.nav-tab {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    border: none;
    background: transparent;
    color: #6B7280;
    font-size: 14px;
    font-weight: 500;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.nav-tab:hover {
    background: #F3F4F6;
    color: #374151;
}

.nav-tab.active {
    background: #3B82F6;
    color: white;
}

.nav-tab svg {
    width: 20px;
    height: 20px;
}

/* Tab Content */
.tab-content {
    position: relative;
}

.tab-panel {
    display: none;
    animation: fadeIn 0.3s ease-in;
}

.tab-panel.active {
    display: block;
}

/* Secret Key Management Styles */
.secret-code-cell {
    display: flex;
    align-items: center;
    gap: 8px;
}

.secret-code {
    font-family: 'Courier New', monospace;
    font-size: 13px;
    background: #F3F4F6;
    padding: 4px 8px;
    border-radius: 4px;
    color: #374151;
}

.btn-reveal {
    background: none;
    border: none;
    color: #6B7280;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.btn-reveal:hover {
    background: #F3F4F6;
    color: #374151;
}

.status-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.status-active {
    background: #D1FAE5;
    color: #065F46;
}

.status-inactive {
    background: #FEE2E2;
    color: #991B1B;
}

.usage-count {
    font-size: 14px;
    color: #6B7280;
}

.action-buttons {
    display: flex;
    gap: 4px;
}

.btn-icon {
    background: none;
    border: none;
    color: #6B7280;
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-icon:hover {
    background: #F3F4F6;
}

.btn-icon.btn-view:hover {
    color: #3B82F6;
}

.btn-icon.btn-activate:hover {
    color: #10B981;
}

.btn-icon.btn-deactivate:hover {
    color: #F59E0B;
}

.btn-icon.btn-delete:hover {
    color: #EF4444;
}

/* Generate Key Modal Styles */
.generated-key-result {
    background: #F0FDF4;
    border: 1px solid #BBF7D0;
    border-radius: 8px;
    padding: 20px;
    margin-top: 20px;
}

.generated-key-result h3 {
    color: #166534;
    margin-bottom: 16px;
    font-size: 18px;
}

.key-display {
    margin-bottom: 16px;
}

.key-display label {
    display: block;
    font-weight: 500;
    margin-bottom: 8px;
    color: #374151;
}

.key-value {
    display: flex;
    align-items: center;
    gap: 12px;
    background: white;
    padding: 12px;
    border-radius: 6px;
    border: 1px solid #D1D5DB;
}

.key-value code {
    font-family: 'Courier New', monospace;
    font-size: 16px;
    color: #1F2937;
    flex: 1;
}

.btn-copy {
    background: #3B82F6;
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    transition: all 0.2s ease;
}

.btn-copy:hover {
    background: #2563EB;
}

.key-info {
    color: #DC2626;
    font-size: 14px;
}

.key-info p {
    margin: 0;
}

/* Form Groups in Modal */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-weight: 500;
    margin-bottom: 6px;
    color: #374151;
}

.required {
    color: #EF4444;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #D1D5DB;
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.2s ease;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: #3B82F6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.form-group input[type="checkbox"] {
    width: auto;
    margin-right: 8px;
}

.input-hint {
    font-size: 12px;
    color: #6B7280;
    margin-top: 4px;
}

/* Key Details Modal */
.key-details {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.detail-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.detail-group label {
    font-weight: 600;
    color: #374151;
}

.detail-group p {
    color: #6B7280;
    margin: 0;
}

.code-display {
    display: flex;
    align-items: center;
    gap: 12px;
    background: #F3F4F6;
    padding: 12px;
    border-radius: 6px;
}

.code-display code {
    font-family: 'Courier New', monospace;
    font-size: 16px;
    color: #1F2937;
    flex: 1;
}

.usage-history {
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid #E5E7EB;
    border-radius: 6px;
    padding: 8px;
}

.usage-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    border-bottom: 1px solid #F3F4F6;
}

.usage-item:last-child {
    border-bottom: none;
}

.usage-time {
    font-size: 12px;
    color: #6B7280;
}

.usage-ip {
    font-size: 12px;
    color: #9CA3AF;
    font-family: 'Courier New', monospace;
}

/* No Data State */
.no-data-cell {
    text-align: center;
    padding: 40px 20px;
    color: #6B7280;
}

.no-data-cell svg {
    margin-bottom: 16px;
    color: #D1D5DB;
}

.no-data-cell p {
    margin-bottom: 16px;
    font-size: 16px;
}

/* Pagination Styles */
.btn-page {
    background: white;
    border: 1px solid #D1D5DB;
    color: #374151;
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 40px;
}

.btn-page:hover:not(:disabled) {
    background: #F3F4F6;
}

.btn-page.active {
    background: #3B82F6;
    color: white;
    border-color: #3B82F6;
}

.btn-page:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.page-dots {
    padding: 8px 12px;
    color: #6B7280;
}

/* Notification Styles */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    background: white;
    border-radius: 8px;
    padding: 16px 20px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    gap: 12px;
    z-index: 1000;
    animation: slideIn 0.3s ease-out;
    max-width: 400px;
}

.notification-success {
    border-left: 4px solid #10B981;
    color: #065F46;
}

.notification-error {
    border-left: 4px solid #EF4444;
    color: #991B1B;
}

.notification-info {
    border-left: 4px solid #3B82F6;
    color: #1E40AF;
}

.notification svg {
    flex-shrink: 0;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Responsive Design */
@media (max-width: 768px) {
    .nav-tabs {
        flex-direction: column;
        gap: 4px;
    }
    
    .nav-tab {
        padding: 10px 16px;
    }
    
    .action-buttons {
        flex-direction: column;
        gap: 2px;
    }
    
    .btn-icon {
        padding: 4px;
    }
    
    .key-value {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    .code-display {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    .usage-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 2px;
    }
    
    .notification {
        right: 10px;
        left: 10px;
        max-width: none;
    }
}
