/* Reset and base styles */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f5f5f5;
    min-height: 100vh;
}

/* Container layouts */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

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

/* Header styles */
.header, .admin-header {
    background: white;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
}

.header h1, .admin-header h1 {
    color: #2c3e50;
    font-size: 1.8em;
    margin-bottom: 0;
}

/* Info text */
.info-text {
    background: white;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    border-left: 4px solid #3498db;
}

.info-text p {
    margin-bottom: 12px;
    color: #2c3e50;
    line-height: 1.6;
}

.info-text p:last-child {
    margin-bottom: 0;
}

.info-text a {
    color: #3498db;
    text-decoration: none;
    font-weight: 500;
}

.info-text a:hover {
    text-decoration: underline;
}

/* Connection status */
.connection-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9em;
}

.status-indicator {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    display: inline-block;
}

.status-indicator.connected {
    background-color: #27ae60;
}

.status-indicator.disconnected {
    background-color: #e74c3c;
}

/* Sessions container */
.sessions-container {
    display: flex;
    flex-direction: column;
    gap: 32px;
}

/* Individual session block */
.session-block {
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    overflow: hidden;
    transition: box-shadow 0.3s ease;
}

.session-block:hover {
    box-shadow: 0 6px 12px rgba(0,0,0,0.15);
}

/* Session header */
.session-header {
    background: linear-gradient(135deg, #3498db, #2980b9);
    color: white;
    padding: 24px 32px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.session-date {
    font-size: 1.8em;
    font-weight: 700;
    margin: 0;
    text-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.session-user-count {
    color: rgba(255,255,255,0.9);
    font-size: 0.9em;
    background: rgba(255,255,255,0.1);
    padding: 8px 12px;
    border-radius: 20px;
    backdrop-filter: blur(10px);
}

/* Session slots container */
.session-slots {
    padding: 32px;
}

.no-sessions {
    background: white;
    border-radius: 8px;
    padding: 40px 20px;
    text-align: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    color: #7f8c8d;
}

/* Time slots container */
.time-slots-container {
    background: white;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.slots-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
    margin-top: 20px;
}

/* Time slot styles */
.time-slot {
    border: 2px solid #ddd;
    border-radius: 8px;
    padding: 16px;
    transition: all 0.3s ease;
    background: white;
}

.time-slot.available {
    border-color: #27ae60;
    background: #f8fff9;
}

.time-slot.reserved {
    border-color: #e74c3c;
    background: #fff5f5;
}

.time-slot.disabled {
    border-color: #bdc3c7;
    background: #f8f9fa;
    opacity: 0.6;
}

.time-label {
    display: block;
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 12px;
    font-size: 1.1em;
}

.input-container {
    position: relative;
}

.family-name-input {
    width: 100%;
    padding: 12px;
    border: 2px solid #ddd;
    border-radius: 6px;
    font-size: 16px;
    transition: border-color 0.3s ease;
}

.family-name-input:focus {
    outline: none;
    border-color: #3498db;
}

.time-slot.reserved .family-name-input {
    border-color: #e74c3c;
    background: #fff;
    font-weight: 600;
}

.clear-btn {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: #e74c3c;
    color: white;
    border: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    transition: background-color 0.2s ease;
}

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

.disabled-message {
    display: block;
    text-align: center;
    color: #7f8c8d;
    font-style: italic;
    padding: 12px;
}

/* Status messages */
.loading, .error-message {
    background: white;
    border-radius: 8px;
    padding: 40px 20px;
    text-align: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.error-message {
    background: #fff5f5;
    border: 2px solid #e74c3c;
    color: #c0392b;
}

.error-text {
    color: #e74c3c;
    font-style: italic;
    text-align: center;
    padding: 20px;
}

.no-slots {
    color: #7f8c8d;
    font-style: italic;
    text-align: center;
    padding: 20px;
}

/* Admin styles */
.auth-section {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 60vh;
}

.auth-card {
    background: white;
    border-radius: 8px;
    padding: 40px;
    max-width: 500px;
    width: 100%;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    text-align: center;
}

.auth-card h2 {
    color: #2c3e50;
    margin-bottom: 16px;
}

.auth-card p {
    color: #7f8c8d;
    margin-bottom: 16px;
}

.auth-card code {
    background: #f8f9fa;
    padding: 4px 8px;
    border-radius: 4px;
    color: #e74c3c;
    font-size: 0.9em;
}

.auth-form {
    display: flex;
    gap: 12px;
    margin-top: 24px;
}

.auth-form input {
    flex: 1;
    padding: 12px;
    border: 2px solid #ddd;
    border-radius: 6px;
    font-size: 16px;
}

/* Admin sections */
.admin-section {
    background: white;
    border-radius: 8px;
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.admin-section h2 {
    color: #2c3e50;
    margin-bottom: 20px;
    border-bottom: 2px solid #ecf0f1;
    padding-bottom: 12px;
}

.admin-section h3 {
    color: #34495e;
    margin-bottom: 16px;
    margin-top: 24px;
}

.admin-section h3:first-of-type {
    margin-top: 0;
}

/* Form styles */
.form-group {
    margin-bottom: 16px;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 6px;
    color: #2c3e50;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 12px;
    border: 2px solid #ddd;
    border-radius: 6px;
    font-size: 16px;
    transition: border-color 0.3s ease;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: #3498db;
}

/* Button styles */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 6px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-block;
    text-align: center;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.btn:active {
    transform: translateY(0);
}

.btn-primary {
    background: #3498db;
    color: white;
}

.btn-primary:hover {
    background: #2980b9;
}

.btn-secondary {
    background: #95a5a6;
    color: white;
}

.btn-secondary:hover {
    background: #7f8c8d;
}

.btn-success {
    background: #27ae60;
    color: white;
}

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

.btn-warning {
    background: #f39c12;
    color: white;
}

.btn-warning:hover {
    background: #e67e22;
}

.btn-danger {
    background: #e74c3c;
    color: white;
}

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

.btn-sm {
    padding: 6px 12px;
    font-size: 14px;
}

/* Session cards */
.sessions-list {
    margin-top: 20px;
}

.session-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border: 2px solid #ecf0f1;
    border-radius: 8px;
    margin-bottom: 12px;
    transition: border-color 0.3s ease;
}

.session-card:hover {
    border-color: #3498db;
}

.session-info h4 {
    color: #2c3e50;
    margin-bottom: 8px;
}

.session-info p {
    color: #7f8c8d;
    margin-bottom: 4px;
    font-size: 0.9em;
}

.session-actions {
    display: flex;
    gap: 12px;
    flex-shrink: 0;
}

/* Slot controls */
.slots-controls {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

/* Admin slots grid */
.admin-slots-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 16px;
    margin-top: 20px;
}

.admin-slot {
    border: 2px solid #ddd;
    border-radius: 8px;
    padding: 16px;
    background: white;
    transition: border-color 0.3s ease;
}

.admin-slot.available {
    border-color: #27ae60;
    background: #f8fff9;
}

.admin-slot.reserved {
    border-color: #e74c3c;
    background: #fff5f5;
}

.admin-slot.disabled {
    border-color: #bdc3c7;
    background: #f8f9fa;
    opacity: 0.7;
}

.slot-time {
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 8px;
    font-size: 1.1em;
}

.slot-status {
    color: #7f8c8d;
    margin-bottom: 12px;
    font-size: 0.9em;
}

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

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

.stat-card {
    background: #ecf0f1;
    border-radius: 8px;
    padding: 20px;
    text-align: center;
}

.stat-number {
    display: block;
    font-size: 2em;
    font-weight: bold;
    color: #2c3e50;
}

.stat-label {
    color: #7f8c8d;
    font-size: 0.9em;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Reservations list */
.reservations-list h3 {
    margin-bottom: 16px;
}

.reservation-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    border: 1px solid #ecf0f1;
    border-radius: 6px;
    margin-bottom: 8px;
    background: white;
}

.reservation-time {
    font-weight: 600;
    color: #2c3e50;
}

.reservation-family {
    flex: 1;
    margin: 0 16px;
}

.reservation-actions {
    flex-shrink: 0;
}

/* Loading overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255,255,255,0.9);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #ecf0f1;
    border-left: 4px solid #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 16px;
}

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

/* Toast notifications */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1100;
    pointer-events: none;
}

.toast {
    background: #2c3e50;
    color: white;
    padding: 12px 20px;
    border-radius: 6px;
    margin-bottom: 8px;
    transform: translateX(400px);
    opacity: 0;
    transition: all 0.3s ease;
    pointer-events: auto;
    max-width: 300px;
    word-wrap: break-word;
}

.toast.show {
    transform: translateX(0);
    opacity: 1;
}

.toast.success {
    background: #27ae60;
}

.toast.error {
    background: #e74c3c;
}

.toast.warning {
    background: #f39c12;
}

.toast.info {
    background: #3498db;
}

/* Close button for error messages */
.close-btn {
    position: absolute;
    top: 8px;
    right: 12px;
    background: none;
    border: none;
    font-size: 18px;
    color: #c0392b;
    cursor: pointer;
    font-weight: bold;
}

.close-btn:hover {
    color: #a93226;
}

/* Responsive design */
@media (max-width: 768px) {
    .container, .admin-container {
        padding: 10px;
    }
    
    .header, .admin-header {
        flex-direction: column;
        text-align: center;
        gap: 16px;
    }
    
    .sessions-container {
        gap: 24px;
    }
    
    .session-header {
        flex-direction: column;
        gap: 12px;
        text-align: center;
        padding: 20px;
    }
    
    .session-date {
        font-size: 1.4em;
    }
    
    .session-slots {
        padding: 20px;
    }
    
    .slots-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    .admin-slots-container {
        grid-template-columns: 1fr;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .session-card {
        flex-direction: column;
        gap: 16px;
        text-align: center;
    }
    
    .session-actions {
        justify-content: center;
    }
    
    .reservation-item {
        flex-direction: column;
        gap: 12px;
        text-align: center;
    }
    
    .reservations-stats {
        grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    }
    
    .slots-controls {
        justify-content: center;
    }
    
    .auth-form {
        flex-direction: column;
    }
    
    .toast-container {
        right: 10px;
        left: 10px;
    }
    
    .toast {
        max-width: none;
    }
}

@media (max-width: 480px) {
    .header h1, .admin-header h1 {
        font-size: 1.4em;
    }
    
    .slots-controls {
        flex-direction: column;
    }
    
    .slot-actions {
        justify-content: center;
    }
}

/* Accessibility improvements */
.btn:focus,
.family-name-input:focus,
input:focus,
select:focus {
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.3);
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .time-slot.available {
        border-width: 3px;
        border-color: #196f27;
    }
    
    .time-slot.reserved {
        border-width: 3px;
        border-color: #c0392b;
    }
    
    .time-slot.disabled {
        border-width: 3px;
        border-color: #7f8c8d;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    * {
        transition: none !important;
        animation: none !important;
    }
    
    .loading-spinner {
        animation: none;
        border-left-color: #3498db;
    }
}

/* Print styles */
@media print {
    .connection-status,
    .toast-container,
    .loading-overlay,
    .btn,
    .clear-btn {
        display: none !important;
    }
    
    .container, .admin-container {
        max-width: none;
        padding: 0;
    }
    
    .time-slot {
        break-inside: avoid;
        border-color: #000 !important;
    }
}

/* Audit Log Styles */
.log-controls {
    display: grid;
    grid-template-columns: 1fr 1fr auto auto;
    gap: 16px;
    align-items: end;
    margin-bottom: 20px;
}

.log-stats {
    display: flex;
    gap: 16px;
    margin-bottom: 24px;
    justify-content: center;
}

.logs-container {
    background: white;
    border-radius: 8px;
    border: 1px solid #e1e8ed;
    overflow: hidden;
}

.logs-table {
    display: flex;
    flex-direction: column;
}

.log-header {
    display: grid;
    grid-template-columns: 80px 100px 140px 1fr 120px;
    gap: 12px;
    padding: 12px 16px;
    background: #f8f9fa;
    border-bottom: 1px solid #e1e8ed;
    font-weight: 600;
    font-size: 0.9em;
    color: #2c3e50;
}

.log-entry {
    display: grid;
    grid-template-columns: 80px 100px 140px 1fr 120px;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid #f1f3f4;
    font-size: 0.9em;
    transition: background-color 0.2s ease;
}

.log-entry:hover {
    background-color: #f8f9fa;
}

.log-entry:last-child {
    border-bottom: none;
}

.log-time {
    font-family: 'Courier New', monospace;
    color: #7f8c8d;
    font-size: 0.85em;
}

.log-session {
    color: #3498db;
    font-weight: 500;
}

.log-operation {
    font-weight: 500;
}

.log-family {
    color: #2c3e50;
}

.log-ip {
    font-family: 'Courier New', monospace;
    color: #95a5a6;
    font-size: 0.85em;
}

/* Operation-specific styling */
.operation-reserve {
    border-left: 4px solid #27ae60;
}

.operation-clear {
    border-left: 4px solid #e74c3c;
}

.operation-slot_enabled {
    border-left: 4px solid #27ae60;
}

.operation-slot_disabled {
    border-left: 4px solid #f39c12;
}

.operation-session_created {
    border-left: 4px solid #3498db;
}

.operation-slot_created {
    border-left: 4px solid #9b59b6;
}

.operation-slot_deleted {
    border-left: 4px solid #e74c3c;
}

.logs-placeholder {
    padding: 40px 20px;
    text-align: center;
    color: #7f8c8d;
}

/* Mobile responsive for logs */
@media (max-width: 768px) {
    .log-controls {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    .log-header,
    .log-entry {
        grid-template-columns: 1fr;
        gap: 4px;
    }
    
    .log-header span,
    .log-entry span {
        padding: 4px 0;
    }
    
    .log-header span:before {
        content: attr(data-label) ': ';
        font-weight: 600;
        color: #7f8c8d;
        display: inline-block;
        min-width: 80px;
    }
    
    .log-stats {
        flex-direction: column;
        gap: 12px;
    }
}