/* ============================================
   iOS Dialog System Styles
   All dialogs built with span/div - no native controls
   ============================================ */

/* ---------- Overlay ---------- */
.ios-dialog-overlay {
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.35);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    animation: ios-fade-in 0.2s ease;
}

/* ---------- Dialog Box ---------- */
.ios-dialog-box {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 14px;
    width: 90%;
    max-width: 320px;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    overflow: hidden;
    transform: scale(0.95);
    opacity: 0;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

.ios-dialog-content {
    padding: 20px;
}

.ios-dialog-title {
    font-size: 17px;
    font-weight: 600;
    color: #000;
    margin-bottom: 8px;
    line-height: 1.3;
}

.ios-dialog-message {
    font-size: 14px;
    color: #3c3c43;
    line-height: 1.5;
    word-break: break-word;
}

/* ---------- Prompt Input ---------- */
.ios-dialog-input-wrap {
    margin-top: 12px;
}

.ios-dialog-input {
    width: 100%;
    padding: 10px 14px;
    font-size: 15px;
    border: 1px solid rgba(0,0,0,0.1);
    border-radius: 10px;
    background: #f2f2f7;
    color: #000;
    outline: none;
    box-sizing: border-box;
    -webkit-appearance: none;
    appearance: none;
}

.ios-dialog-input:focus {
    border-color: #007aff;
    background: #fff;
}

/* ---------- Dialog Actions ---------- */
.ios-dialog-actions {
    display: flex;
    border-top: 1px solid rgba(0,0,0,0.08);
}

.ios-dialog-actions-2 .ios-dialog-btn {
    width: 50%;
}

.ios-dialog-actions-2 .ios-dialog-btn:first-child {
    border-right: 1px solid rgba(0,0,0,0.08);
}

.ios-dialog-btn {
    display: block;
    flex: 1;
    padding: 12px;
    font-size: 16px;
    font-weight: 500;
    text-align: center;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    transition: background 0.15s;
    border: none;
    background: transparent;
}

.ios-dialog-btn:hover {
    background: rgba(0,0,0,0.04);
}

.ios-dialog-btn:active {
    background: rgba(0,0,0,0.08);
}

.ios-dialog-btn-primary {
    color: #007aff;
    font-weight: 600;
}

.ios-dialog-btn-danger {
    color: #ff3b30;
    font-weight: 600;
}

.ios-dialog-btn-default {
    color: #007aff;
}

/* ---------- Toast ---------- */
.ios-toast {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%) translateY(0);
    background: rgba(0, 0, 0, 0.8);
    color: #fff;
    padding: 10px 18px;
    border-radius: 20px;
    font-size: 14px;
    z-index: 999999;
    pointer-events: none;
    white-space: nowrap;
    transition: opacity 0.3s, transform 0.3s;
    animation: ios-toast-in 0.3s ease;
}

.ios-toast-success {
    background: rgba(52, 199, 89, 0.9);
}

.ios-toast-error {
    background: rgba(255, 59, 48, 0.9);
}

/* ---------- Loading ---------- */
.ios-loading-overlay {
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.25);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.ios-loading-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 20px 24px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 14px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}

.ios-loading-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid rgba(0, 122, 255, 0.2);
    border-top-color: #007aff;
    border-radius: 50%;
    animation: ios-spin 0.8s linear infinite;
}

.ios-loading-text {
    font-size: 14px;
    color: #3c3c43;
}

/* ---------- Modal ---------- */
.ios-modal-box {
    background: rgba(255, 255, 255, 0.96);
    border-radius: 14px;
    width: 92%;
    max-width: 520px;
    max-height: 85vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    transform: scale(0.95);
    opacity: 0;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

.ios-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid rgba(0,0,0,0.06);
    flex-shrink: 0;
}

.ios-modal-title {
    font-size: 17px;
    font-weight: 600;
    color: #000;
}

.ios-modal-close {
    font-size: 24px;
    color: #8e8e93;
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.15s, color 0.15s;
}

.ios-modal-close:hover {
    background: rgba(0,0,0,0.06);
    color: #ff3b30;
}

.ios-modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
    color: #000;
}

.ios-modal-footer {
    padding: 12px 20px;
    border-top: 1px solid rgba(0,0,0,0.06);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    flex-shrink: 0;
}

/* ============================================
   Dark Mode
   ============================================ */
[data-theme="dark"] .ios-dialog-overlay {
    background: rgba(0, 0, 0, 0.55);
}

[data-theme="dark"] .ios-dialog-box {
    background: rgba(28, 28, 30, 0.96);
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}

[data-theme="dark"] .ios-dialog-title {
    color: #fff;
}

[data-theme="dark"] .ios-dialog-message {
    color: rgba(255, 255, 255, 0.7);
}

[data-theme="dark"] .ios-dialog-input {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.1);
    color: #fff;
}

[data-theme="dark"] .ios-dialog-input:focus {
    background: rgba(255, 255, 255, 0.15);
    border-color: #0a84ff;
}

[data-theme="dark"] .ios-dialog-actions {
    border-top-color: rgba(255, 255, 255, 0.08);
}

[data-theme="dark"] .ios-dialog-actions-2 .ios-dialog-btn:first-child {
    border-right-color: rgba(255, 255, 255, 0.08);
}

[data-theme="dark"] .ios-dialog-btn:hover {
    background: rgba(255, 255, 255, 0.06);
}

[data-theme="dark"] .ios-dialog-btn:active {
    background: rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .ios-dialog-btn-primary {
    color: #0a84ff;
}

[data-theme="dark"] .ios-dialog-btn-danger {
    color: #ff453a;
}

[data-theme="dark"] .ios-dialog-btn-default {
    color: #0a84ff;
}

[data-theme="dark"] .ios-toast {
    background: rgba(255, 255, 255, 0.9);
    color: #000;
}

[data-theme="dark"] .ios-toast-success {
    background: rgba(48, 209, 88, 0.9);
    color: #000;
}

[data-theme="dark"] .ios-toast-error {
    background: rgba(255, 69, 58, 0.9);
    color: #fff;
}

[data-theme="dark"] .ios-loading-overlay {
    background: rgba(0, 0, 0, 0.4);
}

[data-theme="dark"] .ios-loading-box {
    background: rgba(28, 28, 30, 0.95);
}

[data-theme="dark"] .ios-loading-spinner {
    border-color: rgba(10, 132, 255, 0.2);
    border-top-color: #0a84ff;
}

[data-theme="dark"] .ios-loading-text {
    color: rgba(255, 255, 255, 0.7);
}

[data-theme="dark"] .ios-modal-box {
    background: rgba(28, 28, 30, 0.96);
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}

[data-theme="dark"] .ios-modal-header {
    border-bottom-color: rgba(255, 255, 255, 0.08);
}

[data-theme="dark"] .ios-modal-title {
    color: #fff;
}

[data-theme="dark"] .ios-modal-close {
    color: rgba(255, 255, 255, 0.5);
}

[data-theme="dark"] .ios-modal-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #ff453a;
}

[data-theme="dark"] .ios-modal-body {
    color: rgba(255, 255, 255, 0.85);
}

[data-theme="dark"] .ios-modal-footer {
    border-top-color: rgba(255, 255, 255, 0.08);
}

/* ============================================
   Animations
   ============================================ */
@keyframes ios-fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes ios-toast-in {
    from { opacity: 0; transform: translateX(-50%) translateY(10px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

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

/* ============================================
   iOS Select (Action Sheet)
   ============================================ */
.ios-select-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.35);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 99999;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    animation: ios-fade-in 0.2s ease;
}

.ios-select-sheet {
    background: #f2f2f7;
    border-radius: 14px 14px 0 0;
    padding: 8px;
    padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
    max-height: 70vh;
    overflow-y: auto;
    transform: translateY(0);
    animation: ios-sheet-up 0.3s ease;
}

.ios-select-title {
    text-align: center;
    font-size: 13px;
    color: #8e8e93;
    padding: 10px;
    font-weight: 500;
}

.ios-select-group {
    background: #fff;
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 8px;
}

.ios-select-option {
    display: block;
    padding: 14px 16px;
    font-size: 16px;
    color: #007aff;
    text-align: center;
    cursor: pointer;
    border-bottom: 1px solid rgba(0,0,0,0.04);
    transition: background 0.15s;
    user-select: none;
}

.ios-select-option:hover {
    background: rgba(0,0,0,0.03);
}

.ios-select-option:active {
    background: rgba(0,0,0,0.06);
}

.ios-select-option.selected {
    color: #007aff;
    font-weight: 600;
}

.ios-select-option.selected::after {
    content: '\2713';
    margin-left: 8px;
}

.ios-select-cancel {
    display: block;
    padding: 14px;
    font-size: 16px;
    font-weight: 600;
    color: #007aff;
    text-align: center;
    cursor: pointer;
    background: #fff;
    border-radius: 12px;
    transition: background 0.15s;
    user-select: none;
}

.ios-select-cancel:hover {
    background: #e5e5ea;
}

.ios-select-trigger {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: var(--bg-secondary, #fff);
    border: 1px solid var(--border-color, rgba(0,0,0,0.1));
    border-radius: 8px;
    font-size: 14px;
    color: var(--text-primary, #000);
    cursor: pointer;
    user-select: none;
    transition: border-color 0.2s;
}

.ios-select-trigger:hover {
    border-color: #007aff;
}

.ios-select-trigger::after {
    content: '';
    width: 0; height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 5px solid currentColor;
    opacity: 0.5;
}

/* Dark mode select */
[data-theme="dark"] .ios-select-overlay {
    background: rgba(0,0,0,0.55);
}

[data-theme="dark"] .ios-select-sheet {
    background: #1c1c1e;
}

[data-theme="dark"] .ios-select-title {
    color: rgba(255,255,255,0.5);
}

[data-theme="dark"] .ios-select-group {
    background: rgba(255,255,255,0.1);
}

[data-theme="dark"] .ios-select-option {
    color: #0a84ff;
    border-bottom-color: rgba(255,255,255,0.05);
}

[data-theme="dark"] .ios-select-option:hover {
    background: rgba(255,255,255,0.05);
}

[data-theme="dark"] .ios-select-option:active {
    background: rgba(255,255,255,0.08);
}

[data-theme="dark"] .ios-select-option.selected {
    color: #0a84ff;
}

[data-theme="dark"] .ios-select-cancel {
    color: #0a84ff;
    background: rgba(255,255,255,0.1);
}

[data-theme="dark"] .ios-select-cancel:hover {
    background: rgba(255,255,255,0.15);
}

[data-theme="dark"] .ios-select-trigger {
    background: rgba(255,255,255,0.08);
    border-color: rgba(255,255,255,0.1);
    color: rgba(255,255,255,0.9);
}

[data-theme="dark"] .ios-select-trigger:hover {
    border-color: #0a84ff;
}

@keyframes ios-sheet-up {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

/* ============================================
   iOS Checkbox (Switch)
   ============================================ */
.ios-checkbox-wrap {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    user-select: none;
}

.ios-checkbox-track {
    width: 50px;
    height: 30px;
    background: #e5e5ea;
    border-radius: 15px;
    position: relative;
    transition: background 0.25s ease;
    flex-shrink: 0;
}

.ios-checkbox-track.on {
    background: #34c759;
}

.ios-checkbox-thumb {
    width: 26px;
    height: 26px;
    background: #fff;
    border-radius: 50%;
    position: absolute;
    top: 2px;
    left: 2px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.15);
    transition: transform 0.25s ease;
}

.ios-checkbox-track.on .ios-checkbox-thumb {
    transform: translateX(20px);
}

.ios-checkbox-label {
    font-size: 14px;
    color: var(--text-primary, #000);
}

/* Dark mode checkbox */
[data-theme="dark"] .ios-checkbox-track {
    background: rgba(255,255,255,0.2);
}

[data-theme="dark"] .ios-checkbox-track.on {
    background: #30d158;
}

[data-theme="dark"] .ios-checkbox-label {
    color: rgba(255,255,255,0.9);
}
