/* Admin Panel Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f5f5f5;
    color: #333;
    line-height: 1.6;
}

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

/* Header */
header {
    background: linear-gradient(135deg, #375DA4 0%, #4A825A 100%);
    color: white;
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

header h1 {
    font-size: 2rem;
    font-weight: 300;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

/* Buttons */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-block;
}

.btn-primary {
    background-color: #007bff;
    color: white;
}

.btn-primary:hover {
    background-color: #0056b3;
    transform: translateY(-2px);
}

.btn-secondary {
    background-color: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background-color: #545b62;
    transform: translateY(-2px);
}

.btn-danger {
    background-color: #dc3545;
    color: white;
    padding: 5px 10px;
    font-size: 12px;
}

.btn-danger:hover {
    background-color: #c82333;
}

.btn-edit {
    background-color: #28a745;
    color: white;
    padding: 5px 10px;
    font-size: 12px;
    margin-right: 5px;
}

.btn-edit:hover {
    background-color: #218838;
}

/* Sections */
.section {
    margin-bottom: 30px;
}

.hidden {
    display: none !important;
}

/* Login Form */
.login-form {
    background: white;
    padding: 40px;
    border-radius: 10px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    max-width: 400px;
    margin: 0 auto;
}

.login-form h2 {
    text-align: center;
    margin-bottom: 30px;
    color: #333;
}

/* Panels */
.panel {
    background: white;
    padding: 30px;
    border-radius: 10px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    margin-bottom: 30px;
}

.panel h2 {
    margin-bottom: 20px;
    color: #333;
    border-bottom: 2px solid #007bff;
    padding-bottom: 10px;
}

.user-list-filter {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
}

.user-list-filter label {
    font-weight: 500;
    white-space: nowrap;
}

.user-list-filter input {
    flex: 1;
    min-width: 0;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 14px;
}

.user-list-filter input:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}

.user-list-filter span {
    color: #666;
    font-size: 0.9rem;
    white-space: nowrap;
}

/* Forms */
.form-group {
    margin-bottom: 20px;
}

.form-group.full-width {
    grid-column: 1 / -1;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

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

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

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}

/* Users Table */
.users-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
}

.users-table th,
.users-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #ddd;
}

.users-table th {
    background-color: #f8f9fa;
    font-weight: 600;
    color: #555;
}

.users-table tr:hover {
    background-color: #f8f9fa;
}

.users-table .actions {
    display: flex;
    gap: 6px;
    white-space: nowrap;
}

.users-table .actions .action-icon {
    width: 34px;
    height: 34px;
    margin: 0;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 34px;
    font-size: 18px;
    line-height: 1;
}

.users-table .last-login {
    white-space: nowrap;
}

/* Messages */
.message {
    padding: 10px;
    border-radius: 5px;
    margin-top: 15px;
}

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

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

.error-message {
    color: #dc3545;
    margin-top: 10px;
    font-size: 14px;
}

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

.modal-content {
    background: white;
    padding: 0;
    border-radius: 10px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    padding: 20px 30px;
    border-bottom: 1px solid #ddd;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: #f8f9fa;
    border-radius: 10px 10px 0 0;
}

.modal-header h3 {
    margin: 0;
    color: #333;
}

.close {
    font-size: 24px;
    cursor: pointer;
    color: #999;
    transition: color 0.3s ease;
}

.close:hover {
    color: #333;
}

.modal form {
    padding: 30px;
}

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 20px;
}

/* Role badges */
.role-badge {
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
    text-transform: uppercase;
}

.role-admin {
    background-color: #dc3545;
    color: white;
    text-transform: none;
    white-space: normal;
}

.role-user {
    background-color: #28a745;
    color: white;
    text-transform: none;
}

.role-checkboxes {
    margin: 10px 0 16px;
}
.role-checkboxes .role-hint,
.user-form-section .role-hint {
    margin: 0 0 8px;
    font-size: 0.8rem;
    color: #666;
    line-height: 1.35;
}
.role-checkboxes .role-check {
    display: block;
    margin: 4px 0;
    font-weight: 400;
}

/* Compact create/edit user dialogs */
.user-form-modal {
    width: min(100% - 2rem, 460px) !important;
    max-width: 460px !important;
    max-height: min(92vh, 760px);
    display: flex;
    flex-direction: column;
}
.user-form-modal .modal-header {
    padding: 14px 18px;
    flex-shrink: 0;
}
.user-form-modal .modal-header h3 {
    font-size: 1.1rem;
}
.user-form-modal form {
    padding: 14px 18px 18px;
    overflow-y: auto;
}
.user-form-modal .user-form-section {
    margin: 0 0 14px;
    padding: 10px 12px 4px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    min-width: 0;
}
.user-form-modal .user-form-section legend {
    padding: 0 6px;
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    color: #6b7280;
}
.user-form-modal .form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px 12px;
    margin-bottom: 0;
}
.user-form-modal .form-row:has(.form-group-narrow) {
    grid-template-columns: 1fr minmax(72px, 100px);
}
.user-form-modal .form-group {
    margin-bottom: 10px;
    min-width: 0;
}
.user-form-modal .form-group label {
    margin-bottom: 3px;
    font-size: 0.82rem;
}
.user-form-modal .form-group input,
.user-form-modal .form-group select {
    padding: 8px 10px;
    font-size: 0.92rem;
}
.user-form-modal .role-checkboxes-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px 10px;
    margin: 0 0 8px;
}
.user-form-modal .role-check {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 0;
    font-size: 0.85rem;
    line-height: 1.3;
}
.user-form-modal .role-check input {
    width: auto;
    margin: 0;
    flex-shrink: 0;
}
.user-form-modal .modal-actions {
    margin-top: 4px;
    padding-top: 12px;
    border-top: 1px solid #eee;
    gap: 8px;
}
.user-form-modal .message {
    margin: 0 18px 14px;
}
@media (max-width: 520px) {
    .user-form-modal {
        width: min(100% - 1rem, 460px) !important;
    }
    .user-form-modal .form-row,
    .user-form-modal .form-row:has(.form-group-narrow),
    .user-form-modal .role-checkboxes-grid {
        grid-template-columns: 1fr;
    }
}

/* Admin Navigation */
.admin-nav {
    background: white;
    border-radius: 10px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    margin-bottom: 30px;
    overflow: hidden;
}

.nav-menu {
    list-style: none;
    display: flex;
    margin: 0;
    padding: 0;
}

.nav-item {
    flex: 1;
}

.nav-link {
    display: block;
    padding: 15px 20px;
    text-decoration: none;
    color: #666;
    font-weight: 500;
    text-align: center;
    transition: all 0.3s ease;
    border-bottom: 3px solid transparent;
}

.nav-link:hover {
    background-color: #f8f9fa;
    color: #007bff;
}

.nav-link.active {
    color: #007bff;
    background-color: #f8f9fa;
    border-bottom-color: #007bff;
}

/* Areas Table */
.areas-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
}

.areas-table th,
.areas-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #ddd;
}

.areas-table th {
    background-color: #f8f9fa;
    font-weight: 600;
    color: #555;
}

.areas-table tr:hover {
    background-color: #f8f9fa;
}

.areas-table .actions {
    white-space: nowrap;
}

/* Status badges */
.status-badge {
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
    text-transform: uppercase;
}

.fee-yes, .visible-yes, .bookable-yes {
    background-color: #28a745;
    color: white;
}

.fee-no, .visible-no, .bookable-no {
    background-color: #dc3545;
    color: white;
}

/* Form improvements for area forms */
.form-group input[type="number"] {
    width: 100%;
}

/* Enhanced modal for areas */
.modal-content {
    max-width: 600px;
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    header {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .users-table {
        font-size: 14px;
    }
    
    .users-table th,
    .users-table td {
        padding: 8px;
    }
    
    .modal-content {
        width: 95%;
        margin: 20px;
    }
    
    .panel {
        padding: 20px;
    }
}

/* Loading spinner */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #007bff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Email Settings Styles */
.section-header {
    font-size: 1.2rem;
    font-weight: 600;
    color: #667eea;
    margin: 25px 0 15px 0;
    padding-bottom: 8px;
    border-bottom: 2px solid #667eea;
}

#emailSettingsForm .form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 15px;
}

#emailSettingsForm .form-group label {
    display: flex;
    align-items: center;
    gap: 8px;
}

#emailSettingsForm input[type="checkbox"] {
    width: auto;
    margin: 0;
    cursor: pointer;
}

#emailSettingsMessage {
    padding: 12px;
    margin-bottom: 20px;
    border-radius: 5px;
    display: none;
}

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

#emailSettingsMessage.error {
    display: block;
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

#emailSettingsMessage:empty {
    display: none;
}
