/**
 * ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 *  IFTINA VIDEO CONSULTATIONS — STYLESHEET
 * ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 *
 *  Design System:
 *    Primary:   #0f766e (Teal)
 *    Surface:   #0f172a (Slate 900)
 *    Card:      #1e293b (Slate 800)
 *    Text:      #f8fafc (Slate 50)
 *    Danger:    #ef4444 (Red 500)
 *    Warning:   #f59e0b (Amber 500)
 *    Success:   #22c55e (Green 500)
 */

/* ═══════════════════════════════════════════
   RESET & BASE
   ═══════════════════════════════════════════ */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

.iftina-video-body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: #0f172a;
    color: #f8fafc;
    overflow: hidden;
    height: 100vh;
    height: 100dvh;
    width: 100vw;
    direction: rtl;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ═══════════════════════════════════════════
   APP CONTAINER
   ═══════════════════════════════════════════ */
.iftina-app {
    position: relative;
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    width: 100%;
    max-width: 100%;
    overflow: hidden;
}

/* ═══════════════════════════════════════════
   HEADER: Logo + Timer + Status
   ═══════════════════════════════════════════ */
.iftina-header {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    background: linear-gradient(180deg, rgba(15, 23, 42, 0.9) 0%, rgba(15, 23, 42, 0) 100%);
    pointer-events: none;
}

.iftina-header > * {
    pointer-events: auto;
}

.iftina-header__logo {
    flex-shrink: 0;
}

.iftina-logo {
    height: 40px;
    width: auto;
    max-width: 140px;
    object-fit: contain;
    filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.3));
}

/* Timer */
.iftina-header__timer {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(15, 23, 42, 0.75);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(248, 250, 252, 0.1);
    border-radius: 100px;
    padding: 8px 16px;
    font-variant-numeric: tabular-nums;
}

.iftina-timer__icon {
    display: flex;
    align-items: center;
    color: #22c55e;
}

.iftina-timer__display {
    font-size: 18px;
    font-weight: 600;
    letter-spacing: 0.05em;
    color: #f8fafc;
}

.iftina-timer__display.warning {
    color: #f59e0b;
    animation: timerPulse 1s infinite;
}

.iftina-timer__display.danger {
    color: #ef4444;
    animation: timerPulse 0.5s infinite;
}

@keyframes timerPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Connection Status */
.iftina-header__status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: rgba(248, 250, 252, 0.7);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #f59e0b;
    flex-shrink: 0;
}

.status-dot.connected {
    background: #22c55e;
    box-shadow: 0 0 8px rgba(34, 197, 94, 0.4);
}

.status-dot.disconnected {
    background: #ef4444;
}

.status-dot.connecting {
    background: #f59e0b;
    animation: statusBlink 1.5s infinite;
}

@keyframes statusBlink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

/* ═══════════════════════════════════════════
   VIDEO AREA
   ═══════════════════════════════════════════ */
.iftina-video-area {
    flex: 1;
    position: relative;
    background: #0f172a;
    overflow: hidden;
}

/* Remote Video (Full Screen) */
.iftina-video__remote {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #0f172a;
}

.iftina-video__remote video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.iftina-video__placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    color: rgba(248, 250, 252, 0.5);
}

.iftina-avatar {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: rgba(248, 250, 252, 0.05);
    border: 2px solid rgba(248, 250, 252, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    animation: avatarPulse 3s ease-in-out infinite;
}

@keyframes avatarPulse {
    0%, 100% { transform: scale(1); opacity: 0.8; }
    50% { transform: scale(1.05); opacity: 1; }
}

.iftina-waiting-text {
    font-size: 16px;
    font-weight: 500;
}

/* Local Video (PiP) */
.iftina-video__local {
    position: absolute;
    top: 80px;
    left: 20px;
    width: 160px;
    height: 120px;
    border-radius: 12px;
    overflow: hidden;
    background: #1e293b;
    border: 2px solid rgba(248, 250, 252, 0.15);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    z-index: 20;
    transition: all 0.3s ease;
    cursor: grab;
}

.iftina-video__local:hover {
    border-color: rgba(15, 118, 110, 0.5);
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
}

.iftina-video__local video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: scaleX(-1); /* Mirror local video */
}

.iftina-video__local-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(248, 250, 252, 0.3);
}

.iftina-video__local.video-off {
    background: #1e293b;
}

.iftina-video__local.video-off video {
    display: none;
}

/* ═══════════════════════════════════════════
   CONTROL BAR
   ═══════════════════════════════════════════ */
.iftina-controls {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 30;
    padding: 16px 24px 32px;
    background: linear-gradient(0deg, rgba(15, 23, 42, 0.95) 0%, rgba(15, 23, 42, 0) 100%);
    display: flex;
    justify-content: center;
}

.iftina-controls__group {
    display: flex;
    align-items: center;
    gap: 16px;
    background: rgba(30, 41, 59, 0.8);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(248, 250, 252, 0.08);
    border-radius: 20px;
    padding: 12px 20px;
}

/* Control Buttons */
.iftina-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    border: none;
    background: none;
    cursor: pointer;
    color: #f8fafc;
    font-family: inherit;
    outline: none;
    -webkit-tap-highlight-color: transparent;
    transition: all 0.2s ease;
}

.iftina-btn--control {
    padding: 12px;
    border-radius: 16px;
    background: rgba(248, 250, 252, 0.08);
    min-width: 64px;
}

.iftina-btn--control:hover {
    background: rgba(248, 250, 252, 0.15);
    transform: translateY(-2px);
}

.iftina-btn--control:active {
    transform: translateY(0);
}

.iftina-btn--control[data-active="false"] {
    background: rgba(239, 68, 68, 0.2);
    color: #fca5a5;
}

.iftina-btn--control[data-active="false"]:hover {
    background: rgba(239, 68, 68, 0.3);
}

.btn-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
}

.btn-label {
    font-size: 11px;
    font-weight: 500;
    opacity: 0.7;
}

/* End Button */
.iftina-btn--end {
    padding: 12px 24px;
    border-radius: 16px;
    background: #ef4444;
    color: white;
    min-width: 80px;
}

.iftina-btn--end:hover {
    background: #dc2626;
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(239, 68, 68, 0.4);
}

.iftina-btn--end:active {
    transform: translateY(0);
}

/* ═══════════════════════════════════════════
   STATUS OVERLAY
   ═══════════════════════════════════════════ */
.iftina-overlay {
    position: absolute;
    inset: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    transition: opacity 0.4s ease, visibility 0.4s ease;
}

.iftina-overlay.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.iftina-overlay__content {
    text-align: center;
    padding: 40px;
    max-width: 460px;
}

.iftina-overlay__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: rgba(15, 118, 110, 0.1);
    border: 2px solid rgba(15, 118, 110, 0.2);
    color: #0f766e;
    margin-bottom: 24px;
}

.iftina-overlay__icon.error {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

.iftina-overlay__icon.success {
    background: rgba(34, 197, 94, 0.1);
    border-color: rgba(34, 197, 94, 0.2);
    color: #22c55e;
}

.iftina-overlay__title {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 12px;
    color: #f8fafc;
}

.iftina-overlay__message {
    font-size: 16px;
    line-height: 1.6;
    color: rgba(248, 250, 252, 0.6);
}

.iftina-overlay__countdown {
    margin-top: 24px;
    font-size: 36px;
    font-weight: 700;
    color: #0f766e;
    font-variant-numeric: tabular-nums;
}

/* ═══════════════════════════════════════════
   CONFIRMATION MODAL
   ═══════════════════════════════════════════ */
.iftina-modal {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.iftina-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
}

.iftina-modal__dialog {
    position: relative;
    background: #1e293b;
    border: 1px solid rgba(248, 250, 252, 0.1);
    border-radius: 20px;
    padding: 32px;
    max-width: 400px;
    width: 100%;
    text-align: center;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.5);
    animation: modalSlideUp 0.3s ease;
}

@keyframes modalSlideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.iftina-modal__icon {
    margin-bottom: 16px;
}

.iftina-modal__title {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 8px;
}

.iftina-modal__text {
    font-size: 14px;
    color: rgba(248, 250, 252, 0.6);
    line-height: 1.6;
    margin-bottom: 24px;
}

.iftina-modal__actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.iftina-btn--secondary {
    padding: 12px 24px;
    border-radius: 12px;
    background: rgba(248, 250, 252, 0.08);
    border: 1px solid rgba(248, 250, 252, 0.1);
    color: #f8fafc;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s ease;
}

.iftina-btn--secondary:hover {
    background: rgba(248, 250, 252, 0.15);
}

.iftina-btn--danger {
    padding: 12px 24px;
    border-radius: 12px;
    background: #ef4444;
    border: none;
    color: white;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s ease;
}

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

/* ═══════════════════════════════════════════
   RESPONSIVE — TABLET
   ═══════════════════════════════════════════ */
@media (max-width: 768px) {
    .iftina-header {
        padding: 12px 16px;
    }

    .iftina-logo {
        height: 32px;
        max-width: 100px;
    }

    .iftina-header__timer {
        padding: 6px 12px;
    }

    .iftina-timer__display {
        font-size: 15px;
    }

    .iftina-header__status .status-text {
        display: none;
    }

    .iftina-video__local {
        width: 120px;
        height: 90px;
        top: 64px;
        left: 12px;
        border-radius: 10px;
    }

    .iftina-controls {
        padding: 12px 16px 28px;
    }

    .iftina-controls__group {
        padding: 10px 16px;
        gap: 12px;
    }

    .iftina-btn--control {
        padding: 10px;
        min-width: 56px;
        border-radius: 14px;
    }

    .iftina-btn--end {
        padding: 10px 20px;
    }

    .iftina-overlay__title {
        font-size: 20px;
    }

    .iftina-overlay__message {
        font-size: 14px;
    }

    .iftina-avatar {
        width: 80px;
        height: 80px;
    }

    .iftina-avatar svg {
        width: 48px;
        height: 48px;
    }
}

/* ═══════════════════════════════════════════
   RESPONSIVE — MOBILE
   ═══════════════════════════════════════════ */
@media (max-width: 480px) {
    .iftina-header {
        padding: 10px 12px;
    }

    .iftina-logo {
        height: 28px;
    }

    .iftina-header__timer {
        padding: 5px 10px;
        gap: 6px;
    }

    .iftina-timer__icon svg {
        width: 14px;
        height: 14px;
    }

    .iftina-timer__display {
        font-size: 14px;
    }

    .iftina-video__local {
        width: 100px;
        height: 75px;
        top: 56px;
        left: 8px;
        border-radius: 8px;
    }

    .iftina-controls__group {
        padding: 8px 14px;
        gap: 10px;
        border-radius: 16px;
    }

    .iftina-btn--control {
        padding: 8px;
        min-width: 50px;
        border-radius: 12px;
    }

    .btn-icon svg {
        width: 20px;
        height: 20px;
    }

    .btn-label {
        font-size: 10px;
    }

    .iftina-btn--end {
        padding: 8px 16px;
        min-width: 60px;
    }

    .iftina-modal__dialog {
        padding: 24px 20px;
        border-radius: 16px;
    }

    .iftina-modal__actions {
        flex-direction: column;
    }
}

/* ═══════════════════════════════════════════
   LANDSCAPE MOBILE
   ═══════════════════════════════════════════ */
@media (max-height: 480px) and (orientation: landscape) {
    .iftina-header {
        padding: 8px 16px;
    }

    .iftina-logo {
        height: 24px;
    }

    .iftina-video__local {
        top: 48px;
        width: 140px;
        height: 80px;
    }

    .iftina-controls {
        padding: 8px 16px 16px;
    }

    .iftina-controls__group {
        padding: 6px 14px;
    }

    .btn-label {
        display: none;
    }
}

/* ═══════════════════════════════════════════
   UTILITY: Safe area insets (notch devices)
   ═══════════════════════════════════════════ */
@supports (padding: env(safe-area-inset-bottom)) {
    .iftina-controls {
        padding-bottom: calc(32px + env(safe-area-inset-bottom));
    }

    .iftina-header {
        padding-top: calc(16px + env(safe-area-inset-top));
    }
}

/* ═══════════════════════════════════════════
   ANIMATIONS
   ═══════════════════════════════════════════ */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.fade-in {
    animation: fadeIn 0.4s ease;
}

/* Screen reader only */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}
