/* ==========================================================================
   Smart BurnAid - Professional iOS Design System
   ========================================================================== */

:root {
    /* Colors */
    --color-primary: #007AFF;
    --color-success: #34C759;
    --color-warning: #FF9500;
    --color-danger: #FF3B30;

    /* Backgrounds */
    --bg-primary: #F2F2F7;
    --bg-secondary: #FFFFFF;
    --bg-tertiary: rgba(118, 118, 128, 0.12);

    /* Text */
    --text-primary: #000000;
    --text-secondary: rgba(60, 60, 67, 0.6);
    --text-tertiary: rgba(60, 60, 67, 0.3);

    /* Separator */
    --separator: rgba(60, 60, 67, 0.12);

    /* Typography */
    --font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'SF Pro Text', 'Helvetica Neue', Arial, sans-serif;

    /* Font Sizes */
    --text-xs: 11px;
    --text-sm: 13px;
    --text-base: 15px;
    --text-md: 17px;
    --text-lg: 20px;
    --text-xl: 22px;
    --text-2xl: 28px;

    /* Radius */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;

    /* Spacing */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 20px;
    --space-6: 24px;
}

/* Reset */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font-family);
    font-size: var(--text-md);
    line-height: 1.4;
    color: var(--text-primary);
    background: var(--bg-primary);
    min-height: 100vh;
    min-height: 100dvh;
    -webkit-font-smoothing: antialiased;
    overflow: hidden;
}

/* App Container */
.app-container {
    width: 100%;
    height: 100vh;
    height: 100dvh;
    background: var(--bg-primary);
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

/* Large screens - wider content area */
@media (min-width: 768px) {
    .main-content {
        max-width: 800px;
        margin: 0 auto;
        padding-left: var(--space-6);
        padding-right: var(--space-6);
    }

    .app-header {
        max-width: 800px;
        margin: 0 auto;
        padding-left: var(--space-6);
        padding-right: var(--space-6);
    }

    .bottom-bar {
        max-width: 800px;
        margin: 0 auto;
    }
}

@media (min-width: 1200px) {
    .main-content {
        max-width: 1000px;
    }

    .app-header {
        max-width: 1000px;
    }

    .bottom-bar {
        max-width: 1000px;
    }
}

/* Status Bar */
.status-bar {
    height: var(--safe-top);
    min-height: 47px;
    flex-shrink: 0;
}

/* Header */
.app-header {
    padding: var(--space-4);
}

.header-content {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.app-icon {
    width: 52px;
    height: 52px;
    border-radius: var(--radius-md);
    overflow: hidden;
}

.app-icon svg {
    width: 100%;
    height: 100%;
}

.header-text h1 {
    font-size: var(--text-xl);
    font-weight: 700;
    letter-spacing: -0.3px;
}

.header-text p {
    font-size: var(--text-sm);
    color: var(--text-secondary);
}

.language-toggle {
    width: 44px;
    height: 32px;
    background: var(--bg-secondary);
    border: 1px solid var(--separator);
    border-radius: var(--radius-sm);
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--color-primary);
    cursor: pointer;
    transition: all 0.2s;
    font-family: var(--font-family);
}

.language-toggle:active {
    opacity: 0.7;
}

/* Main Content */
.main-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0 var(--space-4) var(--space-4);
    -webkit-overflow-scrolling: touch;
}

/* Connection Section */
.connection-section {
    margin-bottom: var(--space-4);
}

.connection-card {
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    padding: var(--space-3) var(--space-4);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.connection-status {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.status-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--text-tertiary);
}

.status-indicator.connected {
    background: var(--color-success);
}

.status-indicator.disconnected {
    background: var(--text-tertiary);
}

.connection-info {
    display: flex;
    flex-direction: column;
}

.connection-title {
    font-size: var(--text-base);
    font-weight: 600;
}

.connection-subtitle {
    font-size: var(--text-xs);
    color: var(--text-secondary);
}

.connect-btn {
    padding: 6px 14px;
    background: var(--bg-tertiary);
    border: none;
    border-radius: var(--radius-sm);
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--text-tertiary);
    font-family: var(--font-family);
}

.connect-btn:not(:disabled) {
    background: var(--color-primary);
    color: white;
    cursor: pointer;
}

.connection-hint {
    font-size: var(--text-xs);
    color: var(--text-tertiary);
    text-align: center;
    margin-top: var(--space-2);
}

/* Section Header */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-3);
}

.section-header h2 {
    font-size: var(--text-lg);
    font-weight: 700;
}

.section-badge {
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--color-primary);
    background: rgba(0, 122, 255, 0.1);
    padding: 4px 10px;
    border-radius: 100px;
}

/* Input Form */
.input-form {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.input-card {
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    padding: var(--space-4);
}

.input-card.disabled {
    opacity: 0.5;
}

.input-header {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    margin-bottom: var(--space-3);
}

.input-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

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

.temp-icon {
    background: #FF6B6B;
}

.humidity-icon {
    background: #4FACFE;
}

.resistance-icon {
    background: #A78BFA;
}

.input-label {
    display: flex;
    flex-direction: column;
}

.label-title {
    font-size: var(--text-base);
    font-weight: 600;
}

.label-unit {
    font-size: var(--text-xs);
    color: var(--text-secondary);
}

.input-field {
    display: flex;
    align-items: center;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.input-field input {
    flex: 1;
    border: none;
    background: transparent;
    padding: var(--space-3);
    font-size: var(--text-xl);
    font-weight: 600;
    font-family: var(--font-family);
    color: var(--text-primary);
    text-align: right;
    -webkit-appearance: none;
    -moz-appearance: textfield;
}

.input-field input::-webkit-outer-spin-button,
.input-field input::-webkit-inner-spin-button {
    -webkit-appearance: none;
}

.input-field input::placeholder {
    color: var(--text-tertiary);
}

.input-field input:focus {
    outline: none;
}

.input-suffix {
    padding: var(--space-3);
    font-size: var(--text-md);
    font-weight: 500;
    color: var(--text-secondary);
}

.input-range {
    display: flex;
    justify-content: space-between;
    margin-top: var(--space-2);
    font-size: var(--text-xs);
    color: var(--text-tertiary);
}

/* Buttons */
.action-buttons {
    margin-top: var(--space-4);
}

.btn-primary {
    width: 100%;
    padding: var(--space-4);
    background: var(--color-primary);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-size: var(--text-md);
    font-weight: 600;
    font-family: var(--font-family);
    cursor: pointer;
    transition: opacity 0.2s;
}

.btn-primary:hover {
    opacity: 0.9;
}

.btn-primary:active {
    opacity: 0.8;
}

.btn-secondary {
    width: 100%;
    padding: var(--space-4);
    background: var(--bg-tertiary);
    color: var(--color-primary);
    border: none;
    border-radius: var(--radius-md);
    font-size: var(--text-md);
    font-weight: 600;
    font-family: var(--font-family);
    cursor: pointer;
    transition: opacity 0.2s;
    margin-top: var(--space-4);
}

.btn-secondary:hover {
    opacity: 0.9;
}

.btn-secondary:active {
    opacity: 0.8;
}

/* Loading Section */
.analysis-loading {
    padding: var(--space-6) 0;
}

.loading-card {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    padding: var(--space-6);
    text-align: center;
}

.loading-spinner {
    width: 48px;
    height: 48px;
    border: 3px solid var(--bg-tertiary);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    margin: 0 auto var(--space-4);
    animation: spin 1s linear infinite;
}

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

.loading-title {
    font-size: var(--text-lg);
    font-weight: 700;
    margin-bottom: var(--space-1);
}

.loading-subtitle {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    margin-bottom: var(--space-4);
}

.loading-progress {
    height: 4px;
    background: var(--bg-tertiary);
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: var(--space-5);
}

.loading-bar {
    height: 100%;
    background: var(--color-primary);
    width: 0%;
    transition: width 0.3s ease;
}

.loading-steps {
    text-align: left;
}

.step {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-2) 0;
    font-size: var(--text-sm);
    color: var(--text-tertiary);
}

.step.active {
    color: var(--text-primary);
}

.step.complete {
    color: var(--color-success);
}

.step-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--bg-tertiary);
    flex-shrink: 0;
}

.step.active .step-dot {
    background: var(--color-primary);
}

.step.complete .step-dot {
    background: var(--color-success);
}

/* Results Section */
.results-section {
    animation: fadeIn 0.4s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Severity Card */
.severity-card {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    padding: var(--space-5);
    margin-bottom: var(--space-4);
}

.severity-header {
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
}

.severity-icon-wrapper {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    flex-shrink: 0;
}

.severity-info {
    flex: 1;
}

.severity-label {
    font-size: var(--text-xs);
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.severity-title {
    font-size: var(--text-lg);
    font-weight: 700;
    margin-top: 2px;
}

.severity-alt {
    font-size: var(--text-sm);
    color: var(--text-secondary);
}

.severity-risk {
    padding: 4px 12px;
    border-radius: 100px;
    font-size: var(--text-xs);
    font-weight: 600;
    text-transform: uppercase;
}

.severity-desc {
    margin-top: var(--space-4);
    font-size: var(--text-base);
    color: var(--text-secondary);
    line-height: 1.5;
}

.severity-meta {
    margin-top: var(--space-4);
    padding-top: var(--space-4);
    border-top: 1px solid var(--separator);
}

.meta-item {
    display: flex;
    justify-content: space-between;
}

.meta-label {
    font-size: var(--text-sm);
    color: var(--text-secondary);
}

.meta-value {
    font-size: var(--text-sm);
    font-weight: 600;
}

/* Severity States */
.severity-superficial .severity-icon-wrapper {
    background: rgba(52, 199, 89, 0.15);
    color: #248A3D;
}

.severity-superficial .severity-title {
    color: #248A3D;
}

.severity-superficial .severity-risk {
    background: rgba(52, 199, 89, 0.15);
    color: #248A3D;
}

.severity-partial .severity-icon-wrapper {
    background: rgba(255, 149, 0, 0.15);
    color: #C93400;
}

.severity-partial .severity-title {
    color: #C93400;
}

.severity-partial .severity-risk {
    background: rgba(255, 149, 0, 0.15);
    color: #C93400;
}

.severity-deep .severity-icon-wrapper {
    background: rgba(255, 59, 48, 0.15);
    color: #D70015;
}

.severity-deep .severity-title {
    color: #D70015;
}

.severity-deep .severity-risk {
    background: rgba(255, 59, 48, 0.15);
    color: #D70015;
}

/* Analysis Breakdown */
.analysis-breakdown {
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    padding: var(--space-4);
    margin-bottom: var(--space-4);
}

.breakdown-title {
    font-size: var(--text-sm);
    font-weight: 600;
    margin-bottom: var(--space-3);
}

.breakdown-grid {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.breakdown-item {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
}

.breakdown-header {
    display: flex;
    justify-content: space-between;
    font-size: var(--text-sm);
}

.breakdown-label {
    color: var(--text-secondary);
}

.breakdown-value {
    font-weight: 600;
}

.breakdown-bar {
    height: 6px;
    background: var(--bg-tertiary);
    border-radius: 3px;
    overflow: hidden;
}

.breakdown-fill {
    height: 100%;
    width: 0%;
    transition: width 0.8s ease;
    border-radius: 3px;
}

.breakdown-fill.superficial {
    background: var(--color-success);
}

.breakdown-fill.partial {
    background: var(--color-warning);
}

.breakdown-fill.deep {
    background: var(--color-danger);
}

/* Metrics Grid */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--space-2);
    margin-bottom: var(--space-4);
}

.metric-card {
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    padding: var(--space-3);
    text-align: center;
}

.metric-value {
    font-size: var(--text-base);
    font-weight: 700;
    display: block;
}

.metric-label {
    font-size: 10px;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

/* Guidance Section */
.guidance-section {
    margin-bottom: var(--space-4);
}

.guidance-header {
    margin-bottom: var(--space-3);
}

.guidance-header h3 {
    font-size: var(--text-md);
    font-weight: 700;
}

.guidance-card {
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    padding: var(--space-4);
    margin-bottom: var(--space-3);
}

.guidance-card h4 {
    font-size: var(--text-base);
    font-weight: 600;
    margin-bottom: var(--space-3);
}

.guidance-card ul {
    list-style: none;
}

.guidance-card li {
    position: relative;
    padding-left: var(--space-4);
    margin-bottom: var(--space-2);
    font-size: var(--text-sm);
    color: var(--text-secondary);
    line-height: 1.5;
}

.guidance-card li::before {
    content: '';
    position: absolute;
    left: 0;
    top: 7px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
}

.guidance-card.safe li::before {
    background: var(--color-success);
}

.guidance-card.warning li::before {
    background: var(--color-danger);
}

/* Disclaimer */
.disclaimer-card {
    background: rgba(255, 149, 0, 0.08);
    border-radius: var(--radius-md);
    padding: var(--space-4);
    margin-bottom: var(--space-4);
}

.disclaimer-content strong {
    font-size: var(--text-sm);
    display: block;
    margin-bottom: var(--space-1);
}

.disclaimer-content p {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    line-height: 1.5;
}

/* Tab Bar */
.tab-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-around;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    padding: var(--space-2) 0;
    padding-bottom: calc(var(--space-2) + 20px);
    border-top: 1px solid var(--separator);
}

.tab-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: var(--space-2) var(--space-4);
    color: var(--text-tertiary);
    cursor: pointer;
}

.tab-item svg {
    width: 24px;
    height: 24px;
}

.tab-item span {
    font-size: 10px;
    font-weight: 500;
}

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

/* Home Indicator */
.home-indicator {
    position: absolute;
    bottom: 8px;
    left: 50%;
    transform: translateX(-50%);
    width: 134px;
    height: 5px;
    background: var(--text-primary);
    border-radius: 100px;
    opacity: 0.2;
}

/* Install Banner */
.install-banner {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    max-width: 360px;
    width: calc(100% - 40px);
    background: rgba(30, 30, 30, 0.95);
    backdrop-filter: blur(10px);
    border-radius: var(--radius-lg);
    padding: var(--space-4);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    z-index: 1000;
}

.install-text {
    color: white;
}

.install-text strong {
    font-size: var(--text-base);
    display: block;
}

.install-text span {
    font-size: var(--text-xs);
    opacity: 0.7;
}

.install-actions {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.install-btn {
    padding: 8px 16px;
    background: var(--color-primary);
    color: white;
    border: none;
    border-radius: 100px;
    font-size: var(--text-sm);
    font-weight: 600;
    cursor: pointer;
    font-family: var(--font-family);
}

.install-dismiss {
    width: 28px;
    height: 28px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 50%;
    color: white;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Error Toast */
.error-toast {
    position: fixed;
    top: 80px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255, 59, 48, 0.95);
    color: white;
    padding: 12px 20px;
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
    font-weight: 500;
    z-index: 1000;
    animation: slideDown 0.3s ease;
    transition: opacity 0.3s;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(-20px);
    }

    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

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

/* Dark Mode */
@media (prefers-color-scheme: dark) {
    :root {
        --bg-primary: #000000;
        --bg-secondary: #1C1C1E;
        --bg-tertiary: rgba(118, 118, 128, 0.24);
        --text-primary: #FFFFFF;
        --text-secondary: rgba(235, 235, 245, 0.6);
        --text-tertiary: rgba(235, 235, 245, 0.3);
        --separator: rgba(84, 84, 88, 0.65);
    }

    .tab-bar {
        background: rgba(28, 28, 30, 0.95);
    }

    .home-indicator {
        background: white;
    }
}