/* DoctorYa Teleconsulta - Styles */

:root {
    /* DoctorYa Brand Colors */
    --primary: #01B6AF;
    --primary-dark: #00958F;
    --primary-light: #E0F7F5;
    --secondary: #00275E;
    --secondary-light: #E0F2FE;

    /* Semantic Colors */
    --success: #10B981;
    --warning: #F59E0B;
    --danger: #DC2626;
    --info: #3B82F6;

    /* Neutrals */
    --white: #FFFFFF;
    --gray-50: #F9FAFB;
    --gray-100: #F3F4F6;
    --gray-200: #E5E7EB;
    --gray-300: #D1D5DB;
    --gray-400: #9CA3AF;
    --gray-500: #6B7280;
    --gray-600: #4B5563;
    --gray-700: #374151;
    --gray-800: #1F2937;
    --gray-900: #111827;

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 25px 50px -12px rgba(0, 0, 0, 0.25);

    /* Spacing */
    --radius-sm: 8px;
    --radius: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-full: 9999px;

    /* Safe area insets for iOS */
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-left: env(safe-area-inset-left, 0px);
    --safe-right: env(safe-area-inset-right, 0px);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, var(--secondary) 0%, var(--primary-dark) 100%);
    min-height: 100vh;
    color: var(--gray-800);
    overflow: hidden;
}

/* ==================== Loading Screen ==================== */
.loading-screen {
    position: fixed;
    inset: 0;
    background: linear-gradient(135deg, var(--secondary) 0%, var(--primary-dark) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.loading-content {
    text-align: center;
}

.loading-logo {
    width: 120px;
    height: 120px;
    border-radius: var(--radius-lg);
    animation: pulse 2s ease-in-out infinite;
}

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

.loading-dots {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin: 24px 0 16px;
}

.loading-dots span {
    width: 10px;
    height: 10px;
    background: var(--white);
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out both;
}

.loading-dots span:nth-child(1) { animation-delay: -0.32s; }
.loading-dots span:nth-child(2) { animation-delay: -0.16s; }

@keyframes bounce {
    0%, 80%, 100% { transform: scale(0); opacity: 0.5; }
    40% { transform: scale(1); opacity: 1; }
}

.loading-text {
    color: rgba(255, 255, 255, 0.9);
    font-size: 16px;
    font-weight: 500;
}

/* ==================== Error Screen ==================== */
.error-screen {
    position: fixed;
    inset: 0;
    background: var(--gray-50);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999;
}

.error-content {
    text-align: center;
    padding: 40px;
    background: var(--white);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    max-width: 400px;
}

.error-icon {
    width: 80px;
    height: 80px;
    background: #FEE2E2;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
}

.error-icon svg {
    width: 40px;
    height: 40px;
    color: var(--danger);
}

.error-content h2 {
    color: var(--gray-900);
    font-size: 24px;
    margin-bottom: 8px;
}

.error-content p {
    color: var(--gray-500);
    margin-bottom: 24px;
}

/* ==================== App Container ==================== */
.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    background: var(--gray-100);
}

/* ==================== Header ==================== */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 24px;
    background: var(--white);
    border-bottom: 1px solid var(--gray-200);
    z-index: 100;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.header-logo {
    width: 44px;
    height: 44px;
    border-radius: var(--radius);
}

.header-info h1 {
    font-size: 18px;
    font-weight: 700;
    color: var(--gray-900);
}

.call-timer {
    font-size: 14px;
    font-weight: 600;
    color: var(--primary);
    font-variant-numeric: tabular-nums;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.connection-status {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: var(--gray-100);
    border-radius: var(--radius-full);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--warning);
    animation: blink 1s infinite;
}

.connection-status.connected .status-dot {
    background: var(--success);
    animation: none;
}

.connection-status.error .status-dot {
    background: var(--danger);
    animation: none;
}

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

.status-text {
    font-size: 13px;
    font-weight: 500;
    color: var(--gray-600);
}

.btn-end-call {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: var(--danger);
    color: var(--white);
    border: none;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-end-call:hover {
    background: #B91C1C;
    transform: scale(1.02);
}

.btn-end-call svg {
    width: 18px;
    height: 18px;
}

/* ==================== Main Content ==================== */
.main-content {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* ==================== Video Section ==================== */
.video-section {
    flex: 1;
    position: relative;
    background: var(--gray-900);
    display: flex;
    align-items: center;
    justify-content: center;
}

.remote-video-container {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

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

.video-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    color: var(--gray-400);
}

.placeholder-avatar {
    width: 120px;
    height: 120px;
    background: var(--gray-800);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.placeholder-avatar svg {
    width: 60px;
    height: 60px;
    color: var(--gray-600);
}

.video-placeholder p {
    font-size: 16px;
    font-weight: 500;
}

.video-placeholder.small {
    gap: 8px;
}

.video-placeholder.small svg {
    width: 32px;
    height: 32px;
}

.remote-name-tag {
    position: absolute;
    bottom: 100px;
    left: 24px;
    padding: 8px 16px;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    border-radius: var(--radius);
    color: var(--white);
    font-size: 14px;
    font-weight: 500;
}

/* Local Video (PiP) */
.local-video-container {
    position: absolute;
    bottom: 100px;
    right: 24px;
    width: 200px;
    height: 150px;
    background: var(--gray-800);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-lg);
    border: 3px solid var(--white);
}

.local-video-container .video-player {
    transform: scaleX(-1);
}

.local-label {
    position: absolute;
    bottom: 8px;
    left: 8px;
    padding: 4px 8px;
    background: rgba(0, 0, 0, 0.6);
    border-radius: var(--radius-sm);
    color: var(--white);
    font-size: 12px;
    font-weight: 500;
}

/* Video Controls */
.video-controls {
    position: absolute;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 12px;
    padding: 12px 20px;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(12px);
    border-radius: var(--radius-full);
}

.control-btn {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    border: none;
    background: var(--gray-700);
    color: var(--white);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.control-btn:hover {
    background: var(--gray-600);
    transform: scale(1.05);
}

.control-btn.active {
    background: var(--primary);
}

.control-btn.active:hover {
    background: var(--primary-dark);
}

.control-btn.muted {
    background: var(--danger);
}

.control-btn svg {
    width: 24px;
    height: 24px;
}

/* ==================== Patient Panel ==================== */
.patient-panel {
    width: 420px;
    background: var(--white);
    border-left: 1px solid var(--gray-200);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: width 0.3s ease;
}

.patient-panel.collapsed {
    width: 60px;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: var(--white);
}

.panel-title {
    display: flex;
    align-items: center;
    gap: 12px;
}

.panel-title svg {
    width: 24px;
    height: 24px;
}

.panel-title h2 {
    font-size: 16px;
    font-weight: 700;
}

.panel-toggle {
    width: 36px;
    height: 36px;
    border: none;
    background: rgba(255, 255, 255, 0.2);
    border-radius: var(--radius-sm);
    color: var(--white);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.panel-toggle:hover {
    background: rgba(255, 255, 255, 0.3);
}

.panel-toggle svg {
    width: 20px;
    height: 20px;
}

/* Patient Info */
.patient-info {
    padding: 20px;
    border-bottom: 1px solid var(--gray-200);
}

.patient-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 16px;
}

.patient-avatar {
    width: 56px;
    height: 56px;
    background: linear-gradient(135deg, var(--info) 0%, #1D4ED8 100%);
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
}

.patient-avatar svg {
    width: 28px;
    height: 28px;
    color: var(--white);
}

.patient-details h3 {
    font-size: 18px;
    font-weight: 700;
    color: var(--gray-900);
    margin-bottom: 4px;
}

.patient-details p {
    font-size: 14px;
    color: var(--gray-500);
}

.patient-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--gray-50);
    border-radius: var(--radius);
}

.stat-item svg {
    width: 20px;
    height: 20px;
    color: var(--primary);
}

.stat-label {
    display: block;
    font-size: 11px;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-value {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--gray-900);
}

/* Info Sections */
.info-section {
    margin-top: 16px;
}

.section-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    font-size: 13px;
    font-weight: 600;
}

.section-header.danger {
    color: var(--danger);
}

.section-header.danger svg {
    width: 16px;
    height: 16px;
}

.section-header.info {
    color: var(--info);
}

.section-header.info svg {
    width: 16px;
    height: 16px;
}

.tags-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.tags-list .tag {
    padding: 6px 12px;
    border-radius: var(--radius-full);
    font-size: 12px;
    font-weight: 500;
}

.tags-list.danger .tag {
    background: #FEE2E2;
    color: var(--danger);
}

.tags-list.info .tag {
    background: #DBEAFE;
    color: var(--info);
}

/* AI Analysis */
.ai-analysis {
    margin: 16px 20px;
    background: linear-gradient(135deg, #F3E8FF 0%, #EDE9FE 100%);
    border-radius: var(--radius-lg);
    overflow: hidden;
    border: 1px solid #E9D5FF;
}

.ai-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    cursor: pointer;
    transition: background 0.2s;
}

.ai-header:hover {
    background: rgba(139, 92, 246, 0.1);
}

.ai-title {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #7C3AED;
    font-weight: 600;
    font-size: 14px;
}

.ai-title svg {
    width: 18px;
    height: 18px;
}

.ai-header > svg {
    width: 20px;
    height: 20px;
    color: #7C3AED;
    transition: transform 0.2s;
}

.ai-header.expanded > svg {
    transform: rotate(180deg);
}

.ai-content {
    padding: 0 16px 16px;
}

.ai-overview {
    font-size: 13px;
    color: var(--gray-700);
    line-height: 1.6;
    margin-bottom: 12px;
}

.ai-section {
    margin-top: 12px;
    padding: 12px;
    background: var(--white);
    border-radius: var(--radius);
}

.ai-section h4 {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 8px;
}

.ai-section.alerts h4 {
    color: var(--danger);
}

.ai-section.medications h4 {
    color: var(--success);
}

.ai-section.diagnoses h4 {
    color: var(--warning);
}

.ai-section h4 svg {
    width: 14px;
    height: 14px;
}

.ai-section ul {
    list-style: none;
    font-size: 12px;
    color: var(--gray-600);
}

.ai-section ul li {
    padding: 4px 0;
    padding-left: 16px;
    position: relative;
}

.ai-section ul li::before {
    content: '';
    position: absolute;
    left: 0;
    top: 10px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    opacity: 0.5;
}

/* History Tabs */
.history-tabs {
    display: flex;
    padding: 0 20px;
    border-bottom: 1px solid var(--gray-200);
    background: var(--gray-50);
}

.tab-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 12px 8px;
    border: none;
    background: none;
    color: var(--gray-500);
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    position: relative;
    transition: color 0.2s;
}

.tab-btn:hover {
    color: var(--gray-700);
}

.tab-btn.active {
    color: var(--primary);
}

.tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 3px;
    background: var(--primary);
    border-radius: 3px 3px 0 0;
}

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

.tab-count {
    padding: 2px 6px;
    background: var(--gray-200);
    border-radius: var(--radius-full);
    font-size: 10px;
    font-weight: 600;
}

.tab-btn.active .tab-count {
    background: var(--primary-light);
    color: var(--primary);
}

/* History Content */
.history-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.records-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.record-card {
    padding: 14px;
    background: var(--gray-50);
    border-radius: var(--radius);
    border: 1px solid var(--gray-200);
    transition: all 0.2s;
}

.record-card:hover {
    background: var(--white);
    border-color: var(--primary);
    box-shadow: var(--shadow);
}

.record-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.record-type {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--gray-900);
}

.record-type svg {
    width: 16px;
    height: 16px;
    color: var(--primary);
}

.record-date {
    font-size: 11px;
    color: var(--gray-500);
}

.record-content {
    font-size: 13px;
    color: var(--gray-600);
    line-height: 1.5;
}

.record-content p {
    margin-bottom: 4px;
}

.record-meds {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--gray-200);
}

.record-meds .med-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 0;
    font-size: 12px;
    color: var(--gray-600);
}

.record-meds .med-item::before {
    content: '';
    width: 5px;
    height: 5px;
    background: var(--primary);
    border-radius: 50%;
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    color: var(--gray-400);
    text-align: center;
}

.empty-state svg {
    width: 48px;
    height: 48px;
    margin-bottom: 12px;
    opacity: 0.5;
}

.empty-state p {
    font-size: 14px;
}

/* Quick Notes */
.quick-notes {
    padding: 16px 20px;
    border-top: 1px solid var(--gray-200);
    background: var(--gray-50);
}

.quick-notes h4 {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 12px;
}

.quick-notes h4 svg {
    width: 16px;
    height: 16px;
    color: var(--primary);
}

.quick-notes textarea {
    width: 100%;
    height: 80px;
    padding: 12px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 13px;
    resize: none;
    transition: border-color 0.2s;
}

.quick-notes textarea:focus {
    outline: none;
    border-color: var(--primary);
}

.btn-save-notes {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    margin-top: 12px;
    padding: 10px;
    background: var(--primary);
    color: var(--white);
    border: none;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-save-notes:hover {
    background: var(--primary-dark);
}

.btn-save-notes svg {
    width: 16px;
    height: 16px;
}

/* ==================== Call Ended Screen ==================== */
.call-ended-screen {
    position: fixed;
    inset: 0;
    background: var(--gray-50);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999;
}

.ended-content {
    text-align: center;
    padding: 48px;
    background: var(--white);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    max-width: 400px;
}

.ended-icon {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 24px;
}

.ended-icon.success {
    background: #D1FAE5;
}

.ended-icon.success svg {
    width: 40px;
    height: 40px;
    color: var(--success);
}

.ended-content h2 {
    font-size: 24px;
    font-weight: 700;
    color: var(--gray-900);
    margin-bottom: 8px;
}

.ended-content p {
    font-size: 16px;
    color: var(--gray-500);
    margin-bottom: 32px;
}

.ended-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* ==================== Buttons ==================== */
.btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 28px;
    background: var(--primary);
    color: var(--white);
    border: none;
    border-radius: var(--radius);
    font-size: 15px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
}

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

/* ==================== Utilities ==================== */
.hidden {
    display: none !important;
}

/* ==================== Responsive ==================== */
@media (max-width: 1200px) {
    .patient-panel {
        width: 360px;
    }
}

@media (max-width: 1024px) {
    .patient-panel {
        position: fixed;
        right: 0;
        top: 0;
        bottom: 0;
        z-index: 200;
        width: 100%;
        max-width: 400px;
        transform: translateX(100%);
        transition: transform 0.3s ease;
    }

    .patient-panel.open {
        transform: translateX(0);
    }

    .local-video-container {
        width: 140px;
        height: 105px;
        bottom: 80px;
        right: 16px;
    }

    .video-controls {
        padding: 10px 16px;
        gap: 8px;
    }

    .control-btn {
        width: 44px;
        height: 44px;
    }

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

    .btn-end-call span {
        display: none;
    }
}

@media (max-width: 640px) {
    .header {
        padding: 10px 16px;
    }

    .header-logo {
        width: 36px;
        height: 36px;
    }

    .header-info h1 {
        font-size: 16px;
    }

    .connection-status {
        padding: 6px 12px;
    }

    .status-text {
        display: none;
    }

    .local-video-container {
        width: 100px;
        height: 75px;
        bottom: 70px;
        right: 12px;
    }

    .remote-name-tag {
        bottom: 70px;
        left: 12px;
        font-size: 12px;
        padding: 6px 12px;
    }
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: var(--gray-100);
}

::-webkit-scrollbar-thumb {
    background: var(--gray-300);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--gray-400);
}
