/**
 * Shared Modal Styles
 * Include this in any page that needs modal dialogs
 * Supports both .modal (tenants) and .modal-overlay (rent-roll) patterns
 * 
 * Z-INDEX HIERARCHY (do not exceed these without updating all layers):
 *   100-1000   = Dropdowns, menus, tooltips
 *   9999       = Carousels, expanded views (rent-roll.html)
 *   10000      = Modals (.modal, .modal-overlay) - forms that need focus
 *   10001      = Confirm dialogs (.confirm-modal) - always on top
 */

/* ============================================
   Modal Overlay (used by vacancy-carveout, etc.)
   ============================================ */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 10000;
}

.modal-overlay.active {
    display: flex;
}

/* ============================================
   Modal Base (used by tenants, units, etc.)
   ============================================ */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 10000;
    align-items: center;
    justify-content: center;
    padding: 16px;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    will-change: opacity;
}

.modal.active {
    display: flex;
}

/* ============================================
   Modal Content Container (shared)
   ============================================ */
.modal-content {
    background: white;
    border-radius: 12px;
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.modal-content.wide {
    max-width: 700px;
}

.modal-content.narrow {
    max-width: 400px;
}

/* ============================================
   Modal Header
   ============================================ */
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid #e5e7eb;
}

.modal-header h2 {
    margin: 0;
    font-size: 1.25rem;
    color: #111827;
}

/* ============================================
   Modal Body
   ============================================ */
.modal-body {
    padding: 20px;
}

.modal-description {
    color: #6b7280;
    margin-bottom: 20px;
}

/* ============================================
   Modal Footer
   ============================================ */
.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 16px 20px;
    border-top: 1px solid #e5e7eb;
}

/* ============================================
   Close Buttons (both patterns)
   ============================================ */
.close-btn,
.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #6b7280;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s;
    line-height: 1;
}

.close-btn:hover,
.modal-close:hover {
    background: #f3f4f6;
    color: #111827;
}

/* ============================================
   Form Controls (for use in modals)
   ============================================ */
.form-control {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 0.9rem;
    box-sizing: border-box;
}

.form-control:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.form-label {
    display: block;
    font-weight: 500;
    margin-bottom: 6px;
    color: #374151;
    font-size: 0.9rem;
}

.form-group {
    margin-bottom: 16px;
}

/* ============================================
   Button Styles
   ============================================ */
.btn {
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 500;
    cursor: pointer;
    border: none;
    font-size: 0.9rem;
    transition: background-color 0.15s ease;
}

.btn-primary {
    background: #3b82f6;
    color: white;
}

.btn-primary:hover {
    background: #2563eb;
}

.btn-secondary {
    background: #f3f4f6;
    color: #374151;
}

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

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

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

.btn-success {
    background: #10b981;
    color: white;
}

.btn-success:hover {
    background: #059669;
}

/* ============================================
   Info Boxes for Modals
   ============================================ */
.modal-info-box {
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 16px;
}

.modal-info-box.info {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
}

.modal-info-box.warning {
    background: #fef3c7;
    border: 1px solid #fcd34d;
}

.modal-info-box.danger {
    background: #fee2e2;
    border: 1px solid #fca5a5;
}

.modal-info-box.success {
    background: #ecfdf5;
    border: 1px solid #6ee7b7;
}

/* ============================================
   Confirm Modal (delete confirmations, etc.)
   ============================================ */
.confirm-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 10001;
    align-items: center;
    justify-content: center;
}

.confirm-modal.active {
    display: flex;
}

/* ============================================
   Grid Layout for Modal Forms
   ============================================ */
.modal-grid {
    display: grid;
    gap: 12px;
}

.modal-grid-2 {
    grid-template-columns: 1fr 1fr;
}

@media (max-width: 480px) {
    .modal-grid-2 {
        grid-template-columns: 1fr;
    }
    
    .modal-content {
        margin: 10px;
        max-height: calc(100vh - 20px);
    }
}

