/* Base Styles - Shared across all pages */
body { 
    font-family: Arial, sans-serif; 
    margin: 20px; 
    background: #f5f5f5; 
}

.container { 
    background: white; 
    padding: 20px; 
    border-radius: 8px; 
    box-shadow: 0 2px 4px rgba(0,0,0,0.1); 
}

/* Header Styles */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.header h1 {
    margin: 0;
    color: #333;
}

/* Role-based visibility - Common for all pages */
.admin-only {
    display: none;
}

/* Show admin-only elements for admin users, but exclude modals */
.admin-user .admin-only:not(.modal) {
    display: block;
}

.admin-user .btn.admin-only {
    display: inline-block;
}

.admin-user table .admin-only {
    display: table-cell;
}

/* Button Base Styles */
.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    text-decoration: none;
    /* display: inline-block; */
    transition: background-color 0.3s;
}

.btn-edit {
    background: #007bff;
    color: white;
    font-size: 12px;
    padding: 4px 8px;
    margin-right: 5px;
}

.btn-edit:hover {
    background: #0056b3;
}

.btn-delete {
    background: #dc3545;
    color: white;
    font-size: 12px;
    padding: 4px 8px;
}

.btn-delete:hover {
    background: #c82333;
}

.btn-primary {
    background: #007bff;
    color: white;
}

.btn-primary:hover {
    background: #0056b3;
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #545b62;
}

/* Table Base Styles */
table { 
    border-collapse: collapse; 
    width: 100%; 
    margin-top: 20px; 
    font-size: 13px;
    position: relative;
}

th, td { 
    border: 1px solid #ddd; 
    padding: 8px; 
    text-align: left; 
}

th { 
    color: white; 
    font-weight: bold; 
    font-size: 12px;
}

/* Sticky action column */
th:last-child,
td:last-child {
    position: sticky;
    right: 0;
    background-color: inherit;
    box-shadow: -2px 0 5px rgba(0,0,0,0.1);
    z-index: 10;
}

tr:nth-child(even) td:last-child {
    background-color: #f9f9f9;
}

tr:nth-child(even) { 
    background-color: #f9f9f9; 
}

/* Modal Base Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    overflow-y: auto;
}

.modal-content {
    background-color: white;
    margin: 2% auto;
    padding: 0;
    border-radius: 8px;
    width: 90%;
    max-width: 600px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #ddd;
    background: #f8f9fa;
    border-radius: 8px 8px 0 0;
}

.modal-header h2 {
    margin: 0;
    color: #333;
}

.close-btn {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #666;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-btn:hover {
    color: #000;
}

/* Form Base Styles */
form {
    padding: 20px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-bottom: 15px;
}

.form-row:last-of-type {
    grid-template-columns: 1fr;
}

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
    color: #333;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    box-sizing: border-box;
    font-family: Arial, sans-serif;
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 5px rgba(0,123,255,0.3);
}

.form-group input[readonly] {
    background-color: #f8f9fa;
    color: #666;
}

.form-help {
    font-size: 12px;
    color: #6c757d;
    margin-top: 5px;
}

.readonly-field {
    background-color: #f8f9fa;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    color: #666;
    font-weight: 600;
}

.form-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    padding-top: 20px;
    border-top: 1px solid #ddd;
}

/* Loading Overlay */
.loading-overlay {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.7);
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: white;
}

.spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #007bff;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Error Container */
.error-container {
    padding: 20px; 
    font-family: Arial, sans-serif;
    text-align: center;
}

.error-container h1 {
    color: #dc3545;
}

.error-container code {
    background: #f8f9fa;
    padding: 10px;
    border-radius: 4px;
    border-left: 4px solid #dc3545;
    display: block;
    margin-top: 10px;
    text-align: left;
}

/* Base Responsive Design */
@media (max-width: 1200px) {
    table {
        font-size: 11px;
    }
    
    th, td {
        padding: 6px;
    }
}

@media (max-width: 768px) {
    .header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    
    .modal-content {
        width: 95%;
        margin: 5% auto;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    table {
        font-size: 10px;
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }
    
    th, td {
        padding: 4px;
    }
    
    .btn {
        font-size: 12px;
        padding: 6px 12px;
    }
    
    .btn-edit, .btn-delete {
        font-size: 10px;
        padding: 3px 6px;
    }
}