/* --- Root Variables --- */
:root {
    /* Material Design 3 Dark Theme Tokens */
    --md-sys-color-background: #111318;
    --md-sys-color-surface: #1E2025;
    --md-sys-color-surface-variant: #44474F;
    --md-sys-color-primary: #A8C7FA;
    --md-sys-color-on-primary: #003063;
    --md-sys-color-primary-container: #00478E;
    --md-sys-color-on-primary-container: #D6E3FF;
    --md-sys-color-secondary: #5DD5FC;
    --md-sys-color-secondary-container: #004F58;
    --md-sys-color-error: #FFB4AB;
    --md-sys-color-on-surface: #E2E2E6;
    --md-sys-color-outline: #8E9099;
    --md-elevation-2: 0px 4px 8px 3px rgba(0,0,0,0.15);
    
    --border-radius-lg: 24px;
    --border-radius-pill: 50px;
}

* { box-sizing: border-box; }

body {
    font-family: 'Heebo', 'Roboto', sans-serif;
    background-color: var(--md-sys-color-background);
    color: var(--md-sys-color-on-surface);
    margin: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden; /* Default for Desktop App-feel */
}

/* --- Header & Stepper --- */
header {
    padding: 20px 40px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--md-sys-color-surface);
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
    z-index: 10;
    flex-shrink: 0; /* Prevent header from shrinking */
}

.app-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--md-sys-color-primary);
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    user-select: none;
}

.app-title:hover {
    opacity: 0.8;
}

.stepper {
    display: flex;
    gap: 15px;
}

.step-dot {
    width: 12px;
    height: 12px;
    background-color: var(--md-sys-color-surface-variant);
    border-radius: 50%;
    transition: all 0.3s ease;
}

.step-dot.active {
    background-color: var(--md-sys-color-primary);
    transform: scale(1.3);
    box-shadow: 0 0 10px var(--md-sys-color-primary);
}

.step-dot.completed {
    background-color: var(--md-sys-color-secondary);
}

/* --- Main Layout --- */
.main-container {
    display: flex; 
    flex-direction: row;
    padding: 40px;
    height: 100%; /* Take remaining height */
    max-width: 2400px;
    margin: 0 auto;
    width: 100%;
    gap: 0; /* Start with no gap (Welcome mode) */
    transition: gap 0.8s cubic-bezier(0.22, 1, 0.36, 1);
    overflow: hidden; /* Prevent double scrollbars on desktop */
}

body:not(.welcome-mode) .main-container {
    gap: 60px; /* Gap between panel and phone on desktop */
}

/* --- Left Panel (Content) --- */
.content-panel {
    position: relative;
    background: var(--md-sys-color-surface);
    border-radius: var(--border-radius-lg);
    padding: 40px;
    box-shadow: var(--md-elevation-2);
    display: flex;
    flex-direction: column;
    flex: 1; /* Take up available space */
    transition: all 0.8s cubic-bezier(0.22, 1, 0.36, 1);
    z-index: 2;
    overflow-y: auto; /* Scroll inside panel if needed */
    height: 100%;
}

.page {
    display: none;
    opacity: 0;
    transition: opacity 0.4s ease-in-out;
    height: 100%;
    flex-direction: column;
}

.page.active {
    display: flex;
    opacity: 1;
}

h2 {
    font-size: 2rem;
    margin-top: 0;
    color: var(--md-sys-color-on-surface);
}

.info-card {
    background: var(--md-sys-color-surface-variant);
    color: var(--md-sys-color-on-primary-container);
    padding: 20px;
    border-radius: 16px;
    margin-bottom: 25px;
    font-size: 1.1rem;
    display: flex;
    align-items: start;
    gap: 15px;
}

.info-card .material-symbols-rounded {
    font-size: 24px;
    color: var(--md-sys-color-primary);
    flex-shrink: 0; /* Prevent icon shrinking */
}

.list-item {
    display: flex;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid #333;
    font-size: 1.1rem;
}

.list-item .icon {
    background: var(--md-sys-color-primary-container);
    color: var(--md-sys-color-on-primary-container);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: 15px;
    font-weight: bold;
    font-size: 0.9rem;
    flex-shrink: 0;
}

/* --- Account List Styles --- */
#account-list {
    margin-top: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 0;
}

.account-card {
    display: flex;
    align-items: center;
    background: var(--md-sys-color-surface-variant);
    padding: 12px 16px;
    border-radius: 12px;
    border-left: 5px solid var(--md-sys-color-outline);
    transition: transform 0.2s;
}

.account-card:hover { transform: translateX(5px); }
.account-icon-wrapper {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: 15px;
    background: rgba(255, 255, 255, 0.1);
    flex-shrink: 0;
}

/* Updated to support both Material Font and SVGs */
.account-icon-wrapper .material-symbols-rounded { font-size: 24px; color: #fff; }
.account-icon-wrapper svg { width: 22px; height: 22px; fill: #fff; }

.account-info { flex-grow: 1; overflow: hidden; }
.account-name { font-size: 1rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.account-type { font-size: 0.8rem; color: var(--md-sys-color-outline); display: flex; align-items: center; gap: 5px; }

/* Account Brand Colors */
/* Google (Blue) */
.acc-google { border-left-color: #4285F4; } 
.acc-google .account-icon-wrapper { background: #4285F4; }

/* Samsung (Dark Blue) */
.acc-samsung { border-left-color: #1428A0; } 
.acc-samsung .account-icon-wrapper { background: #1428A0; }

/* WhatsApp (Green) */
.acc-whatsapp { border-left-color: #25D366; } 
.acc-whatsapp .account-icon-wrapper { background: #25D366; }

/* Exchange/Office (Office Blue) */
.acc-exchange { border-left-color: #D83B01; } 
.acc-exchange .account-icon-wrapper { background: #D83B01; }

/* Telegram (Light Blue) */
.acc-telegram { border-left-color: #24A1DE; } 
.acc-telegram .account-icon-wrapper { background: #24A1DE; }

/* X / Twitter (Black) */
.acc-twitter { border-left-color: #000000; }
.acc-twitter .account-icon-wrapper { background: #000000; }

/* Facebook (Blue) */
.acc-facebook { border-left-color: #1877F2; }
.acc-facebook .account-icon-wrapper { background: #1877F2; }

/* Xiaomi (Orange) */
.acc-xiaomi { border-left-color: #FF6900; }
.acc-xiaomi .account-icon-wrapper { background: #FF6900; }

/* TikTok (Black/Pink mix - simplified to black) */
.acc-tiktok { border-left-color: #000000; }
.acc-tiktok .account-icon-wrapper { background: #000000; }

/* Unknown / Generic (Grey) */
.acc-unknown { border-left-color: #607D8B; }
.acc-unknown .account-icon-wrapper { background: #607D8B; }
/* --- Right Panel (Phone Frame) --- */
.phone-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    /* Animation Initial State */
    width: 0;
    opacity: 0;
    transform: translateX(100px) scale(0.8);
    pointer-events: none;
    overflow: hidden;
    transition: 
        width 0.8s cubic-bezier(0.22, 1, 0.36, 1),
        opacity 0.6s ease-in 0.2s,
        transform 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
}

body:not(.welcome-mode) .phone-panel {
    width: 500px;
    opacity: 1;
    transform: translateX(0) scale(1);
    pointer-events: all;
}

.phone-frame {
    width: 400px; /* Slightly reduced for better fit on laptops */
    height: 650px;
    border: 10px solid #2d2d2d;
    border-radius: 40px;
    background: #000;
    position: relative;
    overflow: hidden;
    box-shadow: 0 20px 50px rgba(0,0,0,0.5);
}

.phone-frame::before {
    content: '';
    position: absolute;
    top: 0; left: 50%; transform: translateX(-50%);
    width: 100px; height: 20px;
    background: #2d2d2d;
    border-bottom-left-radius: 12px; border-bottom-right-radius: 12px;
    z-index: 5;
}

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

.phone-controls { margin-top: 20px; display: flex; gap: 20px; }

/* --- Buttons & Inputs --- */
.btn {
    background-color: var(--md-sys-color-primary);
    color: var(--md-sys-color-on-primary);
    border: none;
    padding: 0 32px;
    height: 48px;
    border-radius: var(--border-radius-pill);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.btn:hover { box-shadow: 0 4px 12px rgba(168, 199, 250, 0.4); transform: translateY(-1px); }
.btn:disabled { background-color: #333; color: #777; cursor: not-allowed; box-shadow: none; transform: none; }
.btn-tonal { background-color: var(--md-sys-color-surface-variant); color: var(--md-sys-color-on-surface); }
.btn-tonal:hover { background-color: #555; }
.btn-beta { background: rgba(255, 152, 0, 0.15); color: #FF9800; border: 1px solid rgba(255, 152, 0, 0.5); }

/* Calm Button - Tonal Yellow Version */
.btn-calm {
    /* Colors: Using Tertiary (often yellow/gold in MD3) or soft custom yellow */
    --bg-color: #ffe676; /* A soft, warm yellow (amber-50) */
    --text-color: #92400e; /* A deep golden brown for contrast */
    --border-color: #f59e0b; /* A medium gold for the border */

    background: var(--bg-color);
    color: var(--text-color);
    border: 1px solid transparent; /* Keep it clean by default */
    
    /* Size: Increased from 32px to 40px for better visibility */
    height: 40px;
    padding: 0 20px;
    border-radius: 12px; /* Slightly rounder for a modern look */
    
    /* Typography */
    font-size: 0.9rem;
    font-weight: 600;
    letter-spacing: 0.2px;
    
    /* Layout */
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

/* Hover: Becomes more "Button-like" but stays calm */
.btn-calm:hover {
    background: #f8e8a5; /* Slightly deeper yellow */
    border-color: var(--border-color);
    color: #78350f;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    transform: translateY(-1px);
}

/* Active: Pressed state */
.btn-calm:active {
    transform: translateY(0px);
    background: #b18e1e;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Icon scaling */
.btn-calm .material-symbols-rounded {
    font-size: 20px; /* Slightly bigger icon to match button size */
}

.action-area {
    margin-top: auto;
    padding-top: 30px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-top: 1px solid var(--md-sys-color-surface-variant);
    gap: 15px;
    flex-wrap: wrap;
}

.status-badge {
    background: rgba(255,255,255,0.05);
    padding: 8px 16px;
    border-radius: 12px;
    font-family: monospace;
    color: var(--md-sys-color-outline);
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}
.status-badge.success { color: #81C784; background: rgba(27, 94, 32, 0.2); }
.status-badge.error { color: #E57373; background: rgba(183, 28, 28, 0.2); }

/* --- Terminal / Log --- */
.terminal {
    background: #0d0d0d;
    color: #e0e0e0;
    font-family: 'Consolas', monospace;
    padding: 15px;
    border-radius: 12px;
    height: 250px;
    overflow-y: auto;
    font-size: 0.85rem;
    border: 1px solid #333;
    line-height: 1.4;
    word-break: break-all;
}

.log-entry { margin-bottom: 4px; border-left: 3px solid transparent; padding-left: 10px; }
.log-info { color: #8e9099; }
.log-success { color: #81C784; border-left-color: #4CAF50; }
.log-error { color: #FFB4AB; background: rgba(255, 180, 171, 0.1); border-left-color: #CF6679; padding: 8px; font-weight: bold; }

#snackbar {
    visibility: hidden;
    min-width: 250px;
    background-color: #333;
    color: #fff;
    text-align: center;
    border-radius: 8px;
    padding: 16px;
    position: fixed;
    z-index: 100;
    left: 50%;
    bottom: 30px;
    transform: translateX(-50%);
    box-shadow: 0 4px 15px rgba(0,0,0,0.5);
    font-size: 1rem;
    max-width: 90%;
}
#snackbar.show { visibility: visible; animation: fadein 0.5s, fadeout 0.5s 2.5s; }

@keyframes fadein { from {bottom: 0; opacity: 0;} to {bottom: 30px; opacity: 1;} }
@keyframes fadeout { from {bottom: 30px; opacity: 1;} to {bottom: 0; opacity: 0;} }

.progress-wrapper { width: 100%; background: #333; height: 6px; border-radius: 3px; margin: 20px 0; overflow: hidden; display: none; }
.progress-fill { height: 100%; width: 0%; background: var(--md-sys-color-primary); transition: width 0.3s ease; }

.warning-box { border: 1px solid #FF9800; background: rgba(255, 152, 0, 0.05); padding: 15px; border-radius: 8px; margin-top: 15px; font-size: 0.9rem; display: none; }

#compatibility-notice { display: none; text-align: center; padding: 30px; background-color: var(--md-sys-color-surface-variant); border-radius: var(--border-radius-lg); }

/* --- Development Console --- */
#dev-console { position: fixed; bottom: 20px; right: 20px; width: 500px; background: #000; border: 1px solid #00ff00; box-shadow: 0 0 20px rgba(0, 255, 0, 0.1); border-radius: 8px; z-index: 9999; font-family: 'Consolas', monospace; display: flex; flex-direction: column; overflow: hidden; }
.dev-header { background: #002200; color: #00ff00; padding: 8px 12px; font-weight: bold; display: flex; justify-content: space-between; border-bottom: 1px solid #00ff00; }
.dev-log { height: 250px; overflow-y: auto; padding: 10px; color: #ccc; font-size: 12px; }
.dev-log-entry { margin-bottom: 5px; border-bottom: 1px solid #222; padding-bottom: 2px; }
.dev-controls { padding: 10px; background: #111; border-top: 1px solid #333; }
.dev-input-group { display: flex; gap: 5px; margin-bottom: 8px; }
.dev-input-group input { flex-grow: 1; background: #222; border: 1px solid #444; color: #fff; padding: 5px; }
.dev-scenarios { display: flex; gap: 5px; flex-wrap: wrap; }
.dev-btn { background: #222; color: #00ff00; border: 1px solid #00ff00; padding: 4px 8px; font-size: 10px; cursor: pointer; text-transform: uppercase; }

/* ========================================= */
/*       RESPONSIVE DESIGN (MOBILE/TABLET)   */
/* ========================================= */

@media (max-width: 1100px) {
    body {
        /* Enable native scrolling on mobile */
        height: auto;
        min-height: 100vh;
        overflow-y: auto;
    }

    header {
        padding: 15px 20px;
    }

    .app-title {
        font-size: 1.2rem;
    }

    .stepper {
        gap: 8px; /* Tighter dots */
    }

    .main-container {
        display: block; /* Remove flex constraint */
        padding: 15px;
        height: auto;
        overflow: visible;
    }

    /* Override Desktop Animation Gap Logic */
    body:not(.welcome-mode) .main-container {
        gap: 0;
    }

    .content-panel {
        width: 100%;
        height: auto;
        min-height: 60vh;
        padding: 25px 20px;
        margin-bottom: 20px;
    }

    /* Hide the Phone Panel on Tablet/Mobile to save space */
    .phone-panel, 
    body:not(.welcome-mode) .phone-panel {
        display: none !important; 
        width: 0;
        margin: 0;
    }

    h2 {
        font-size: 1.5rem;
    }

    .info-card {
        padding: 15px;
        font-size: 1rem;
    }

    .list-item {
        font-size: 1rem;
    }

    /* Action Area: Stack Buttons */
    .action-area {
        flex-direction: column-reverse; /* Status at bottom */
        align-items: stretch; /* Full width items */
        gap: 15px;
    }

    .action-area > div {
        display: flex;
        flex-direction: column;
        gap: 10px;
        width: 100%;
    }

    /* Buttons full width on mobile */
    .btn {
        width: 100%;
        justify-content: center;
    }

    /* Status Badge Centered */
    .status-badge {
        justify-content: center;
        width: 100%;
        margin-top: 10px;
        font-size: 0.9rem;
    }

    /* Adjust Dev Console for small screens */
    #dev-console {
        width: 95%;
        left: 2.5%;
        right: auto;
        bottom: 10px;
    }
}
/* --- Phone Success Screen --- */
#phone-success-message {
    display: none; /* Hidden by default */
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #0f1115 0%, #1a1c23 100%);
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    z-index: 20;
    animation: fadeIn 1s ease;
}

#phone-success-message .icon {
    font-size: 80px;
    color: var(--md-sys-color-secondary);
    margin-bottom: 20px;
    text-shadow: 0 0 30px rgba(93, 213, 252, 0.4);
}

#phone-success-message .text {
    font-size: 1.5rem;
    font-weight: 300;
    color: var(--md-sys-color-on-surface);
    line-height: 1.4;
}

#phone-success-message .brand {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--md-sys-color-primary);
    display: block;
    margin-top: 10px;
    letter-spacing: 2px;
    text-transform: uppercase;
    text-shadow: 0 0 20px rgba(168, 199, 250, 0.3);
}

@keyframes fadeIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}