/* ============================================================
   MUBSIRA BUSINESS -- Sync Panel Styles
   Cross-device transfer UI.
   Matches the Mubsira design system (black & white, SaaS grade).
   ============================================================ */

/* ── Overlay ── */

.sync-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0);
    z-index: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    transition: background 0.25s ease;
    pointer-events: none;
}

.sync-overlay-open {
    background: rgba(0, 0, 0, 0.45);
    pointer-events: auto;
}

.sync-overlay-closing {
    background: rgba(0, 0, 0, 0);
    pointer-events: none;
}

/* ── Panel ── */

.sync-panel {
    background: var(--color-surface, #ffffff);
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2), 0 0 0 1px rgba(0, 0, 0, 0.06);
    width: 100%;
    max-width: 460px;
    max-height: calc(100vh - 2rem);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: translateY(12px) scale(0.97);
    opacity: 0;
    transition: transform 0.25s ease, opacity 0.25s ease;
}

.sync-overlay-open .sync-panel {
    transform: translateY(0) scale(1);
    opacity: 1;
}

.sync-overlay-closing .sync-panel {
    transform: translateY(12px) scale(0.97);
    opacity: 0;
}

/* ── Header ── */

.sync-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem 1rem;
    border-bottom: 1px solid var(--color-border, #e5e5e5);
}

.sync-header-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.sync-header-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: var(--color-primary-light, rgba(79, 70, 229, 0.08));
    color: var(--color-primary, #4f46e5);
    flex-shrink: 0;
}

.sync-header-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--color-text, #0a0a0a);
    line-height: 1.2;
}

.sync-header-subtitle {
    font-size: 0.75rem;
    color: var(--color-text-muted, #737373);
    line-height: 1.3;
    margin-top: 2px;
}

.sync-close-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: none;
    background: transparent;
    color: var(--color-text-muted, #737373);
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    flex-shrink: 0;
    padding: 0;
}

.sync-close-btn:hover {
    background: var(--color-surface-alt, #f5f5f5);
    color: var(--color-text, #0a0a0a);
}

/* ── Body ── */

.sync-body {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 1.25rem 1.5rem;
    min-height: 0;
}

/* ── Footer (Privacy) ── */

.sync-footer {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border-top: 1px solid var(--color-border, #e5e5e5);
    font-size: 0.6875rem;
    color: var(--color-text-muted, #737373);
    line-height: 1.35;
}

.sync-footer-icon {
    display: flex;
    flex-shrink: 0;
    color: var(--color-success, #16a34a);
}

/* ── Mode Selection Grid ── */

.sync-mode-grid {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.sync-mode-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.25rem;
    border: 1px solid var(--color-border, #e5e5e5);
    border-radius: 10px;
    background: var(--color-surface, #ffffff);
    cursor: pointer;
    transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
    text-align: left;
    width: 100%;
    font-family: inherit;
    color: inherit;
}

.sync-mode-card:hover {
    border-color: var(--color-primary, #4f46e5);
    box-shadow: 0 2px 8px rgba(79, 70, 229, 0.08);
}

.sync-mode-card:active {
    background: var(--color-surface-alt, #f5f5f5);
}

.sync-mode-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: var(--color-surface-alt, #f5f5f5);
    color: var(--color-primary, #4f46e5);
    flex-shrink: 0;
}

.sync-mode-card:hover .sync-mode-icon {
    background: var(--color-primary-light, rgba(79, 70, 229, 0.08));
}

.sync-mode-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--color-text, #0a0a0a);
    line-height: 1.2;
}

.sync-mode-desc {
    font-size: 0.75rem;
    color: var(--color-text-muted, #737373);
    line-height: 1.35;
    margin-top: 2px;
}

/* ── Generic View Layout ── */

.sync-view {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.sync-view-center {
    align-items: center;
    text-align: center;
    padding: 1rem 0;
}

/* ── Back Button ── */

.sync-back-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--color-text-muted, #737373);
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    margin-bottom: 0.25rem;
    font-family: inherit;
    transition: color 0.15s;
}

.sync-back-btn:hover {
    color: var(--color-text, #0a0a0a);
}

/* ── Instruction Text ── */

.sync-instruction {
    font-size: 0.875rem;
    color: var(--color-text-secondary, #404040);
    line-height: 1.45;
    text-align: center;
}

/* ── Code Display (Send) ── */

.sync-code-display {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 0;
}

.sync-code-digit {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 56px;
    border-radius: 10px;
    background: var(--color-surface-alt, #f5f5f5);
    border: 2px solid var(--color-border-strong, #d4d4d4);
    font-family: var(--font-mono, monospace);
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--color-text, #0a0a0a);
    letter-spacing: 0;
    user-select: all;
}

/* ── Timer ── */

.sync-timer-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-size: 0.8125rem;
    color: var(--color-text-muted, #737373);
}

.sync-timer-value {
    font-family: var(--font-mono, monospace);
    font-weight: 600;
    color: var(--color-text-secondary, #404040);
    font-size: 0.875rem;
}

/* ── Steps ── */

.sync-steps {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    padding: 0.75rem 0;
}

.sync-step {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.8125rem;
    color: var(--color-text-secondary, #404040);
    line-height: 1.35;
}

.sync-step-number {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--color-primary, #4f46e5);
    color: #ffffff;
    font-size: 0.6875rem;
    font-weight: 700;
    flex-shrink: 0;
}

/* ── Code Input (Receive) ── */

.sync-code-input-row {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem 0;
}

.sync-code-input {
    width: 46px;
    height: 54px;
    border-radius: 10px;
    border: 2px solid var(--color-border, #e5e5e5);
    background: var(--color-surface, #ffffff);
    font-family: var(--font-mono, monospace);
    font-size: 1.375rem;
    font-weight: 700;
    text-align: center;
    color: var(--color-text, #0a0a0a);
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
    caret-color: var(--color-primary, #4f46e5);
    -webkit-appearance: none;
    appearance: none;
    padding: 0;
}

.sync-code-input:focus {
    border-color: var(--color-primary, #4f46e5);
    box-shadow: 0 0 0 3px var(--color-primary-light, rgba(79, 70, 229, 0.08));
}

/* ── Receive Status ── */

.sync-receive-status {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-size: 0.8125rem;
    min-height: 1.5rem;
    color: var(--color-text-muted, #737373);
    text-align: center;
}

.sync-receive-error {
    color: var(--color-danger, #dc2626);
}

.sync-receive-error-icon {
    display: flex;
    flex-shrink: 0;
    color: var(--color-danger, #dc2626);
}

.sync-receive-loading,
.sync-import-loading {
    color: var(--color-primary, #4f46e5);
}

/* ── Buttons ── */

.sync-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    border-radius: 8px;
    font-size: 0.8125rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    border: none;
    transition: background 0.15s, opacity 0.15s;
    min-height: 40px;
}

.sync-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.sync-btn-primary {
    background: var(--color-accent, #0a0a0a);
    color: var(--color-accent-inverse, #ffffff);
}

.sync-btn-primary:hover:not(:disabled) {
    background: var(--color-accent-hover, #262626);
}

.sync-btn-secondary {
    background: var(--color-surface-alt, #f5f5f5);
    color: var(--color-text, #0a0a0a);
    border: 1px solid var(--color-border, #e5e5e5);
}

.sync-btn-secondary:hover:not(:disabled) {
    background: var(--color-border, #e5e5e5);
}

.sync-btn-success {
    background: var(--color-success, #16a34a) !important;
    color: #ffffff !important;
}

.sync-btn-full {
    width: 100%;
}

/* ── File Sections ── */

.sync-file-section {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.sync-file-section-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.sync-file-section-icon {
    display: flex;
    color: var(--color-primary, #4f46e5);
}

.sync-file-section-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--color-text, #0a0a0a);
}

.sync-file-section-desc {
    font-size: 0.8125rem;
    color: var(--color-text-muted, #737373);
    line-height: 1.45;
    margin: 0;
}

.sync-divider {
    height: 1px;
    background: var(--color-border, #e5e5e5);
    margin: 0.5rem 0;
}

/* ── Drop Zone ── */

.sync-drop-zone {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 1.5rem 1rem;
    border: 2px dashed var(--color-border, #e5e5e5);
    border-radius: 10px;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}

.sync-drop-zone:hover,
.sync-drop-active {
    border-color: var(--color-primary, #4f46e5);
    background: var(--color-primary-light, rgba(79, 70, 229, 0.04));
}

.sync-drop-icon {
    display: flex;
    color: var(--color-text-muted, #737373);
}

.sync-drop-zone:hover .sync-drop-icon,
.sync-drop-active .sync-drop-icon {
    color: var(--color-primary, #4f46e5);
}

.sync-drop-text {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--color-text-secondary, #404040);
}

.sync-drop-hint {
    font-size: 0.6875rem;
    color: var(--color-text-muted, #737373);
}

/* ── Import Status ── */

.sync-import-status {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-size: 0.8125rem;
    min-height: 1.25rem;
    color: var(--color-text-muted, #737373);
}

.sync-import-error {
    color: var(--color-danger, #dc2626);
}

/* ── Success View ── */

.sync-success-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--color-success-bg, #f0fdf4);
    color: var(--color-success, #16a34a);
    margin-bottom: 0.25rem;
}

.sync-success-title {
    font-size: 1.0625rem;
    font-weight: 700;
    color: var(--color-text, #0a0a0a);
}

.sync-success-detail {
    font-size: 0.8125rem;
    color: var(--color-text-muted, #737373);
    line-height: 1.45;
}

/* ── Error / Expired Views ── */

.sync-error-icon,
.sync-expired-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--color-warning-bg, #fefce8);
    color: var(--color-warning, #ca8a04);
    margin-bottom: 0.25rem;
}

.sync-error-icon {
    background: var(--color-danger-bg, #fef2f2);
    color: var(--color-danger, #dc2626);
}

.sync-error-title,
.sync-expired-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--color-text, #0a0a0a);
}

.sync-error-detail,
.sync-expired-detail {
    font-size: 0.8125rem;
    color: var(--color-text-muted, #737373);
    line-height: 1.45;
    max-width: 300px;
}

/* ── Status (Loading) ── */

.sync-status {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    padding: 2rem 0;
}

.sync-status-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-primary, #4f46e5);
}

.sync-status-loading {
    color: var(--color-primary, #4f46e5);
}

.sync-status-text {
    font-size: 0.875rem;
    color: var(--color-text-muted, #737373);
}

/* ── Spinner Animation ── */

.sync-spinner {
    animation: sync-spin 0.8s linear infinite;
}

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

/* ── Dark Mode ── */

[data-theme="dark"] .sync-panel {
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.06);
}

[data-theme="dark"] .sync-mode-card:active {
    background: var(--color-surface-alt, #222222);
}

[data-theme="dark"] .sync-close-btn:hover {
    background: var(--color-surface-alt, #222222);
}

[data-theme="dark"] .sync-code-input {
    background: var(--color-surface-alt, #222222);
}

/* ── Mobile Responsive ── */

@media (max-width: 768px) {
    .sync-overlay {
        align-items: flex-end;
        padding: 0;
    }

    .sync-panel {
        max-width: 100%;
        max-height: 92vh;
        border-radius: 16px 16px 0 0;
        transform: translateY(100%);
    }

    .sync-overlay-open .sync-panel {
        transform: translateY(0);
    }

    .sync-overlay-closing .sync-panel {
        transform: translateY(100%);
    }

    .sync-header {
        padding: 1rem 1.25rem 0.875rem;
    }

    .sync-body {
        padding: 1rem 1.25rem;
    }

    .sync-footer {
        padding: 0.75rem 1.25rem;
        padding-bottom: calc(0.75rem + env(safe-area-inset-bottom, 0px));
    }

    .sync-code-display {
        gap: 0.375rem;
    }

    .sync-code-digit {
        width: 42px;
        height: 50px;
        font-size: 1.25rem;
    }

    .sync-code-input-row {
        gap: 0.375rem;
    }

    .sync-code-input {
        width: 42px;
        height: 50px;
        font-size: 1.25rem;
        /* Prevent iOS zoom on focus */
        font-size: max(1.25rem, 16px);
    }

    .sync-mode-card {
        padding: 0.875rem 1rem;
    }
}

/* ── Small phones ── */

@media (max-width: 380px) {
    .sync-code-digit,
    .sync-code-input {
        width: 38px;
        height: 46px;
        font-size: 1.125rem;
    }

    .sync-code-display,
    .sync-code-input-row {
        gap: 0.25rem;
    }
}

/* ── iOS Safari specifics ── */

@supports (-webkit-touch-callout: none) {
    .sync-code-input {
        font-size: 16px; /* Prevent auto-zoom */
    }

    .sync-btn {
        min-height: 44px;
    }

    .sync-mode-card {
        min-height: 44px;
    }
}
