/* ========================================
   Base Styles
   ======================================== */

body {
    font-family: Arial, sans-serif;
    padding: 20px;
}

.dbox_open {
    cursor: pointer;
}

/* ========================================
   Dialog Box
   ======================================== */

#dialog_box {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #F2F9F2;
    border: 4px solid #1A572E;
    border-radius: 8px;
    padding: 0;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    min-width: 300px;
    max-width: 95vw;
    max-height: 95vh;
}

#dialog_box.open {
    display: flex;
    flex-direction: column;
}

/* ========================================
   Title Bar
   ======================================== */

.dialog-title-bar {
    background: linear-gradient(to bottom, #6ab3ff, #007bff);
    color: white;
    padding: 10px 20px;
    border-radius: 4px 4px 0 0;
    border-bottom: 4px solid #1A572E;
    display: flex;
    justify-content: space-between;
    align-items: center;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
    cursor: default;
    flex-shrink: 0;
}

.dialog-title-bar.draggable {
    cursor: grab;
    cursor: -webkit-grab;
}

.dialog-title-bar.dragging {
    cursor: grabbing !important;
    cursor: -webkit-grabbing !important;
}

/* Using div instead of h2 for semantic correctness */
.dialog-title {
    margin: 0;
    font-size: 1.2em;
    font-weight: bold;
    flex: 1;
    cursor: inherit;
    pointer-events: none;
    color: white;
}

/* ========================================
   Close Button
   ======================================== */

.close-x {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 4px solid white;
    border-radius: 50%;
    width: 34px;
    height: 34px;
    min-width: 34px;
    min-height: 34px;
    font-size: 24px;
    font-weight: bold;
    line-height: 1;
    cursor: pointer !important;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: background 0.2s ease;
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
    font-family: Arial, sans-serif;
    pointer-events: auto;
}

.close-x:hover {
    background: rgba(255, 255, 255, 0.9);
    color: #007bff;
}

.close-x:active {
    background: white;
    color: #007bff;
}

/* ========================================
   Content Area
   ======================================== */

.dialog-content {
    padding: 20px;
    display: flex;
    flex-direction: column;
    overflow: auto;
    background: #F2F9F2;
    border-radius: 0 0 4px 4px;
}

.dialog-content.has-buttons {
    border-radius: 0;
}

/* ========================================
   Button Container
   ======================================== */

.dialog-buttons {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    padding: 12px 20px;
    background: #F2F9F2;
    border-top: 2px solid #d0e8d0;
    border-radius: 0 0 4px 4px;
}

.dialog-btn {
    padding: 10px 20px;
    border: 2px solid #1A572E;
    border-radius: 4px;
    background: white;
    color: #1A572E;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 80px;
}

.dialog-btn:hover {
    background: #1A572E;
    color: white;
}

.dialog-btn:active {
    transform: scale(0.98);
}

.dialog-btn.btn-primary {
    background: #007bff;
    color: white;
    border-color: #0056b3;
}

.dialog-btn.btn-primary:hover {
    background: #0056b3;
    border-color: #004085;
}

/* ========================================
   iframe Mode
   ======================================== */

.dialog-content.iframe-mode {
    padding: 0;
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: white;
}

.dialog-iframe {
    width: 100%;
    flex: 1;
    border: none;
    border-radius: 0 0 4px 4px;
    display: block;
}

/* ========================================
   Overlay
   ======================================== */

.overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
}

.overlay.open {
    display: block;
}

/* ========================================
   Mobile Optimizations
   ======================================== */

@media (max-width: 768px) {
    #dialog_box {
        min-width: 280px;
        width: 90vw !important;
        max-width: 90vw;
        border: 3px solid #1A572E;
    }
    
    .dialog-title {
        font-size: 1.1em;
    }
    
    .dialog-title-bar {
        padding: 8px 15px;
        border-bottom: 3px solid #1A572E;
    }
    
    .close-x {
        width: 38px;
        height: 38px;
        min-width: 38px;
        min-height: 38px;
        font-size: 26px;
        border: 4px solid white;
    }
    
    .dialog-content {
        padding: 15px;
    }
    
    .dialog-buttons {
        padding: 10px 15px;
    }
}

@media (max-width: 480px) {
    #dialog_box {
        width: 95vw !important;
        max-width: 95vw;
        max-height: 90vh;
    }
    
    .dialog-title {
        font-size: 1em;
    }
}

/* ============================================
 * ALERT MODE STYLES
 * ============================================
 * Applies when using class="alert_box" trigger
 * or when alertMode: true in JavaScript API
 */

/* Alert-mode dialog: More rounded, compact styling */
#dialog_box.alert-mode {
    border-radius: 16px;  /* More rounded corners */
    max-width: 450px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
}

/* Alert content area */
#dialog_box.alert-mode .dialog-content {
    border-radius: 16px 16px 0 0;
    padding: 30px 25px;
    text-align: center;
}

/* Alert buttons at bottom */
#dialog_box.alert-mode .dialog-buttons {
    border-top: 1px solid #e0e0e0;
    border-radius: 0 0 16px 16px;
    padding: 15px 25px;
    background: #fafafa;
}

/* Alert button styling */
#dialog_box.alert-mode .dialog-btn {
    min-width: 100px;
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 500;
}

/* Primary button in alert mode */
#dialog_box.alert-mode .btn-primary {
    background: #4CAF50;
    color: white;
}

#dialog_box.alert-mode .btn-primary:hover {
    background: #45a049;
}

/* ============================================
 * ALERT CONTENT FORMATTING
 * ============================================ */

/* Large icons in alerts */
#dialog_box.alert-mode .alert-icon {
    font-size: 64px;
    margin-bottom: 20px;
    line-height: 1;
}

/* Alert titles */
#dialog_box.alert-mode .alert-title,
#dialog_box.alert-mode h2 {
    font-size: 24px;
    font-weight: 600;
    color: #333;
    margin: 0 0 15px 0;
}

/* Alert messages */
#dialog_box.alert-mode .alert-message,
#dialog_box.alert-mode p {
    font-size: 16px;
    line-height: 1.6;
    color: #666;
    margin: 0 0 20px 0;
}

#dialog_box.alert-mode p:last-child {
    margin-bottom: 0;
}

/* ============================================
 * ALERT VARIANTS
 * ============================================ */

/* Success alert - green theme */
#dialog_box.alert-mode.alert-success .alert-icon {
    color: #4CAF50;
}

#dialog_box.alert-mode.alert-success .dialog-buttons {
    background: #f1f8f4;
}

/* Warning alert - yellow theme */
#dialog_box.alert-mode.alert-warning .alert-icon {
    color: #FF9800;
}

#dialog_box.alert-mode.alert-warning .dialog-buttons {
    background: #fff8f0;
}

/* Error alert - red theme */
#dialog_box.alert-mode.alert-error .alert-icon {
    color: #f44336;
}

#dialog_box.alert-mode.alert-error .dialog-buttons {
    background: #fef5f5;
}

/* Info alert - blue theme */
#dialog_box.alert-mode.alert-info .alert-icon {
    color: #2196F3;
}

#dialog_box.alert-mode.alert-info .dialog-buttons {
    background: #f0f7ff;
}

/* ============================================
 * RESPONSIVE ADJUSTMENTS
 * ============================================ */

@media (max-width: 500px) {
    #dialog_box.alert-mode {
        max-width: 90vw;
        border-radius: 12px;
    }
    
    #dialog_box.alert-mode .dialog-content {
        padding: 25px 20px;
    }
    
    #dialog_box.alert-mode .alert-icon {
        font-size: 48px;
    }
    
    #dialog_box.alert-mode .alert-title,
    #dialog_box.alert-mode h2 {
        font-size: 20px;
    }
}

