/* =================================
   MODAL SYSTEM - CityKEP
   Centralized modal styles for all pages
   ================================= */

.modal {
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    backdrop-filter: blur(5px);
    display: none;
}

.modal-content {
    background-color: white;
    margin: 5% auto;
    width: 90%;
    max-width: 600px;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    overflow: hidden;
    animation: modalSlideIn 0.3s ease-out;
}

/* Large modal variant */
.modal-content.modal-large {
    max-width: 800px;
}

/* Extra large modal variant */
.modal-content.modal-xl {
    max-width: 1000px;
}

@keyframes modalSlideIn {
    from { transform: translateY(-50px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.modal-header {
    background: linear-gradient(135deg, #35707e, #2a5861);
    color: white;
    padding: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
    line-height: 1.4;
}

.modal-close {
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0 0.5rem;
    border-radius: 4px;
    transition: background-color 0.3s;
    min-width: 30px;
    text-align: center;
    user-select: none;
}

.modal-close:hover {
    background-color: rgba(255,255,255,0.2);
}

.modal-body {
    padding: 2rem;
    max-height: 60vh;
    overflow-y: auto;
}

/* Compact modal body */
.modal-body.modal-compact {
    padding: 1.5rem;
}

.modal-footer {
    padding: 1.5rem;
    background: #f8f9fa;
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    border-top: 1px solid #e9ecef;
}

/* Modal footer variants */
.modal-footer.modal-footer-center {
    justify-content: center;
}

.modal-footer.modal-footer-between {
    justify-content: space-between;
}

/* =================================
   MODAL FORM STYLES
   ================================= */

.modal .form-group {
    margin-bottom: 1.5rem;
}

.modal .form-group label {
    display: block;
    color: #35707e;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.modal .form-group input,
.modal .form-group textarea,
.modal .form-group select {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid #e0e6ed;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.3s ease;
}

.modal .form-group input:focus,
.modal .form-group textarea:focus,
.modal .form-group select:focus {
    outline: none;
    border-color: #35707e;
}

.modal .form-group textarea {
    min-height: 150px;
    resize: vertical;
}

.modal .form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

/* =================================
   MODAL BUTTONS
   ================================= */

.btn-primary {
    background: linear-gradient(135deg, #35707e, #2a5861);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-primary:hover {
    background: linear-gradient(135deg, #2a5861, #1e444c);
    transform: translateY(-1px);
}

.btn-secondary {
    background: #6c757d;
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

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

.btn-danger {
    background: #dc3545;
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-danger:hover {
    background: #c82333;
    transform: translateY(-1px);
}

/* =================================
   SPECIALIZED MODAL CONTENT
   ================================= */

/* Announcement Modal */
.modal-announcement-meta {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
    align-items: center;
}

.modal-announcement-category {
    background: #e3f2fd;
    color: #1565c0;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
}

.modal-announcement-date {
    color: #666;
    font-size: 0.9rem;
}

.modal-announcement-content {
    line-height: 1.6;
    color: #333;
    font-size: 1rem;
    white-space: pre-wrap;
}

/* User Modal */
.modal .checkbox-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.modal .checkbox-group input[type="checkbox"] {
    width: auto;
    margin: 0;
}

/* Status badges in modals */
.status-badge {
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
}

.status-active {
    background: #d4edda;
    color: #155724;
}

.status-inactive {
    background: #f8d7da;
    color: #721c24;
}

.level-badge {
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
}

.level-admin {
    background: #f8d7da;
    color: #721c24;
}

.level-operator {
    background: #cce5ff;
    color: #0056b3;
}

.level-citizen {
    background: #d4edda;
    color: #155724;
}

/* =================================
   RESPONSIVE DESIGN
   ================================= */

@media (max-width: 768px) {
    .modal-content {
        margin: 10% auto;
        width: 95%;
    }
    
    .modal-header {
        padding: 1rem;
    }
    
    .modal-body {
        padding: 1.5rem;
        max-height: 50vh;
    }
    
    .modal-footer {
        padding: 1rem;
        flex-direction: column;
    }
    
    .modal .form-row {
        grid-template-columns: 1fr;
    }
    
    .modal-announcement-meta {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    
    .btn-primary,
    .btn-secondary,
    .btn-danger {
        width: 100%;
        text-align: center;
    }
}

@media (max-width: 480px) {
    .modal-content {
        margin: 5% auto;
        width: 98%;
    }
    
    .modal-header h3 {
        font-size: 1.1rem;
    }
    
    .modal-body {
        padding: 1rem;
    }
    
    .modal-footer {
        padding: 1rem;
    }
}

/* =================================
   UTILITY CLASSES
   ================================= */

.modal-readonly input,
.modal-readonly textarea,
.modal-readonly select {
    background-color: #f8f9fa;
    color: #6c757d;
    cursor: not-allowed;
}

.modal-hidden {
    display: none !important;
}

.modal-loading {
    pointer-events: none;
    opacity: 0.7;
}

.modal-loading .modal-body::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #35707e;
    border-radius: 50%;
    border-top-color: transparent;
    animation: spin 1s linear infinite;
}

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