/* CPN Teacher Substitution System - Styles */

:root {
    --primary: #1e3a5f;
    --primary-light: #2d5a8a;
    --secondary: #e74c3c;
    --success: #27ae60;
    --warning: #f39c12;
    --info: #3498db;
    --light: #f8f9fa;
    --dark: #2c3e50;
    --border: #dee2e6;
    --shadow: 0 2px 10px rgba(0,0,0,0.1);
}

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f0f2f5;
    color: var(--dark);
    line-height: 1.6;
}

/* Header */
.header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    color: white;
    padding: 1rem 2rem;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header h1 {
    font-size: 1.5rem;
    font-weight: 600;
}

.header-subtitle {
    font-size: 0.875rem;
    opacity: 0.9;
}

/* Navigation */
.nav {
    background: white;
    padding: 0.5rem 2rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.nav a {
    color: var(--dark);
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    transition: all 0.2s;
    font-weight: 500;
}

.nav a:hover, .nav a.active {
    background: var(--primary);
    color: white;
}

/* Main Container */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1.5rem;
}

/* Cards */
.card {
    background: white;
    border-radius: 12px;
    box-shadow: var(--shadow);
    margin-bottom: 1.5rem;
    overflow: hidden;
}

.card-header {
    background: var(--light);
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    font-size: 1.1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-body {
    padding: 1.5rem;
}

/* Forms */
.form-group {
    margin-bottom: 1.25rem;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--dark);
}

.form-control {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(30, 58, 95, 0.1);
}

select.form-control {
    cursor: pointer;
    background: white;
}

/* Grid Layout */
.grid {
    display: grid;
    gap: 1.5rem;
}

.grid-2 {
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}

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

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

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

.btn-primary:hover {
    background: var(--primary-light);
}

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

.btn-success:hover {
    background: #219a52;
}

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

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

.btn-secondary {
    background: var(--light);
    color: var(--dark);
    border: 1px solid var(--border);
}

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

.btn-sm {
    padding: 0.4rem 0.8rem;
    font-size: 0.875rem;
}

.btn-block {
    width: 100%;
}

/* Tables */
.table-responsive {
    overflow-x: auto;
}

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

th, td {
    padding: 0.875rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

th {
    background: var(--light);
    font-weight: 600;
    color: var(--dark);
    white-space: nowrap;
}

tr:hover {
    background: #f8f9fa;
}

/* Checkbox styling */
.checkbox-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.checkbox-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--light);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    border: 2px solid transparent;
}

.checkbox-item:hover {
    background: #e9ecef;
}

.checkbox-item.selected {
    background: rgba(30, 58, 95, 0.1);
    border-color: var(--primary);
}

.checkbox-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

/* Period selection */
.period-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 0.5rem;
}

.period-item {
    padding: 0.75rem;
    background: var(--light);
    border: 2px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

.period-item:hover {
    border-color: var(--primary);
}

.period-item.selected {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.period-item.busy {
    background: #ffebee;
    border-color: var(--secondary);
    cursor: not-allowed;
    opacity: 0.7;
}

.period-time {
    font-size: 0.8rem;
    opacity: 0.8;
}

.period-subject {
    font-weight: 600;
    margin-top: 0.25rem;
}

/* Day selector */
.day-selector {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.day-btn {
    width: 50px;
    height: 50px;
    border: 2px solid var(--border);
    border-radius: 10px;
    background: white;
    font-size: 1.25rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.day-btn:hover {
    border-color: var(--primary);
}

.day-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* Results panel */
.results-panel {
    background: var(--light);
    border-radius: 8px;
    padding: 1rem;
    margin-top: 1rem;
}

.substitute-option {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    background: white;
    border-radius: 8px;
    margin-bottom: 0.5rem;
    border: 1px solid var(--border);
    cursor: pointer;
    transition: all 0.2s;
}

.substitute-option:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow);
}

.substitute-option.selected {
    border-color: var(--success);
    background: #e8f5e9;
}

.substitute-option.same-dept {
    border-left: 4px solid var(--success);
}

.teacher-name {
    font-weight: 600;
}

.teacher-dept {
    font-size: 0.85rem;
    color: #666;
}

.sub-count {
    background: var(--info);
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: 12px;
    font-size: 0.8rem;
}

/* Badges */
.badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
}

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

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

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

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

/* Tally card */
.tally-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: white;
    border-radius: 8px;
    margin-bottom: 0.5rem;
    border-left: 4px solid var(--primary);
    cursor: pointer;
    transition: all 0.2s;
}

.tally-card:hover {
    box-shadow: var(--shadow);
}

.tally-count {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: white;
    border-radius: 12px;
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    transform: translateY(-20px);
    transition: transform 0.3s;
}

.modal-overlay.active .modal {
    transform: translateY(0);
}

.modal-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-title {
    font-size: 1.25rem;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #666;
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
}

/* Alerts */
.alert {
    padding: 1rem 1.5rem;
    border-radius: 8px;
    margin-bottom: 1rem;
}

.alert-success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.alert-danger {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.alert-warning {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffeeba;
}

.alert-info {
    background: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

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

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

/* Responsive */
@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }
    
    .header {
        padding: 1rem;
    }
    
    .nav {
        padding: 0.5rem 1rem;
    }
    
    .day-btn {
        width: 40px;
        height: 40px;
        font-size: 1rem;
    }
    
    .grid-2, .grid-3 {
        grid-template-columns: 1fr;
    }
}

/* Utility classes */
.text-center { text-align: center; }
.text-right { text-align: right; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.d-flex { display: flex; }
.justify-between { justify-content: space-between; }
.align-center { align-items: center; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
