/* === Variables === */
:root {
    --primary-blue: #1e3a5f;
    --secondary-blue: #2c5282;
    --light-blue: #4a90e2;
    --hover-blue: #5fa3f5;
    --bg-gray: #edf0f4;
    --panel-bg: #f5f5f5;
    --border-gray: #c0c0c0;
    --text-dark: #333333;
    --text-light: #666666;
    --success-green: #4caf50;
    --warning-orange: #ff9800;
    --danger-red: #f44336;
    --tab-height: 44px;
    --sidebar-width: 180px;
    --bottom-height: 40px;
    --transition-speed: 0.25s;
}

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: 14px;
    background-color: var(--bg-gray);
    color: var(--text-dark);
    overflow-x: hidden;
    overflow-y: auto;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* === Top Tabs === */
.top-tabs {
    display: flex;
    justify-content: center;
    align-items: stretch;
    background: linear-gradient(135deg, var(--primary-blue), var(--secondary-blue));
    border-bottom: none;
    height: 54px;
    max-width: 1600px;
    width: 100%;
    margin: 0 auto;
    padding: 0 20px;
    gap: 4px;
    position: relative;
}

.tab-button {
    background-color: rgba(255, 255, 255, 0.08);
    border: none;
    border-bottom: 3px solid transparent;
    padding: 10px 32px;
    cursor: pointer;
    font-size: 15px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.75);
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all var(--transition-speed);
    position: relative;
    margin: 0;
    border-radius: 0;
}

.tab-button:hover {
    background-color: rgba(255, 255, 255, 0.15);
    color: #fff;
}

.tab-button.active {
    background-color: rgba(255, 255, 255, 0.2);
    border: none;
    border-bottom: 3px solid #5ce0d2;
    margin-bottom: 0;
    color: #fff;
    font-weight: 700;
    box-shadow: none;
}

.tab-button i {
    font-size: 14px;
}

.key-hint {
    font-size: 10px;
    color: rgba(255, 255, 255, 0.6);
    background-color: rgba(255, 255, 255, 0.15);
    padding: 2px 5px;
    border-radius: 3px;
    font-weight: 500;
    font-family: 'Consolas', monospace;
    line-height: 1;
}

.tab-button.active .key-hint {
    background-color: rgba(255, 255, 255, 0.25);
    color: rgba(255, 255, 255, 0.9);
}

/* === Language Selector === */
.lang-selector {
    position: absolute;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 100;
}

.lang-toggle {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 10px;
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    color: #fff;
    cursor: pointer;
    font-size: 18px;
    transition: background var(--transition-speed);
}

.lang-toggle:hover {
    background: rgba(255, 255, 255, 0.25);
}

.lang-arrow {
    font-size: 10px;
    transition: transform 0.2s;
}

.lang-selector.open .lang-arrow {
    transform: rotate(180deg);
}

.lang-dropdown {
    display: none;
    position: absolute;
    right: 0;
    top: calc(100% + 6px);
    background: white;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
    min-width: 160px;
    overflow: hidden;
    z-index: 200;
}

.lang-selector.open .lang-dropdown {
    display: block;
    animation: fadeIn 0.15s ease-out;
}

.lang-option {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 14px;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 14px;
    color: var(--text-dark);
    transition: background 0.15s;
}

.lang-option:hover {
    background: #f0f4ff;
}

.lang-option.active {
    background: #e8f0fe;
    font-weight: 600;
    color: var(--primary-blue);
}

.lang-flag {
    font-size: 20px;
}

.lang-name {
    flex: 1;
}

/* === Main Layout === */
.main-layout {
    display: flex;
    gap: 12px;
    flex: 1;
    min-height: 0;
    max-width: 1600px;
    width: 100%;
    margin: 0 auto;
    padding: 12px 20px;
}

/* === Content Area === */
.content-area {
    flex: 1;
    background: white;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    min-width: 0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

/* === Tab Content with Fade Transition === */
.tab-content {
    display: none;
    padding: 0;
    animation: fadeIn var(--transition-speed) ease-out;
}

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

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

/* === Screenshot Container — Responsive === */
.screen-container {
    width: 100%;
    max-width: 900px;
    aspect-ratio: 16 / 10;
    margin: 0 auto 16px auto;
    border: 2px solid #d0d8e8;
    border-radius: 8px;
    background: #f8f9fa;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    transition: border-color var(--transition-speed);
}

.screen-container:hover {
    border-color: var(--light-blue);
}

.main-screenshot {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    display: block;
    cursor: zoom-in;
    transition: transform 0.2s ease;
}

.main-screenshot:hover {
    transform: scale(1.01);
}

/* Screenshot fade transition */
.screen-container.transitioning .main-screenshot {
    opacity: 0;
    transition: opacity 0.15s ease-out;
}

.screen-container .main-screenshot {
    opacity: 1;
    transition: opacity 0.25s ease-in;
}

/* === Screenshot Comments with Accordion === */
.screenshot-comment {
    max-width: 900px;
    margin: 0 auto;
    background: #f8f9fa;
    padding: 16px 20px;
    border-radius: 8px;
    border: 1px solid #e9ecef;
    font-size: 14px;
    line-height: 1.6;
    height: auto;
    min-height: auto;
}

.screenshot-comment h4 {
    margin: 0 0 8px 0;
    color: var(--primary-blue);
    font-size: 15px;
    font-weight: 600;
}

.screenshot-comment p,
.screenshot-comment div {
    margin: 6px 0;
    color: #34495e;
}

.screenshot-comment strong {
    color: #2c3e50;
    font-weight: 600;
}

.screenshot-comment em {
    color: #7f8c8d;
    font-style: italic;
}

.screenshot-comment ul {
    list-style-type: none;
    padding-left: 15px;
    margin: 8px 0;
}

.screenshot-comment li {
    position: relative;
    padding-left: 18px;
    margin-bottom: 4px;
}

.screenshot-comment li::before {
    content: '\2713';
    position: absolute;
    left: 0;
    top: 0;
    color: #28a745;
    font-weight: bold;
    font-size: 12px;
}

/* Collapsible description */
.description-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: none;
    border: none;
    color: var(--light-blue);
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    padding: 6px 0;
    margin-top: 4px;
    transition: color var(--transition-speed);
}

.description-toggle:hover {
    color: var(--primary-blue);
}

.description-toggle i {
    transition: transform var(--transition-speed);
    font-size: 11px;
}

.description-toggle.expanded i {
    transform: rotate(180deg);
}

.description-details {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s ease, opacity 0.3s ease;
    opacity: 0;
}

.description-details.expanded {
    max-height: 2000px;
    opacity: 1;
}

/* === Right Sidebar === */
.right-sidebar-container {
    flex-shrink: 0;
}

.right-sidebar {
    width: 90px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: #f8f9fa;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.right-sidebar.is-hidden {
    display: none !important;
}

#sidebar-settings {
    display: none !important;
}

.sidebar-btn {
    background-color: var(--primary-blue);
    color: white;
    border: 2px solid transparent;
    padding: 10px 6px;
    cursor: pointer;
    font-size: 13px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    transition: all var(--transition-speed);
    border-radius: 6px;
    position: relative;
}

.sidebar-btn:hover {
    background-color: var(--hover-blue);
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(30, 58, 95, 0.3);
}

.sidebar-btn:active {
    transform: translateY(0);
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.2);
}

/* Active sidebar button */
.sidebar-btn.active {
    background-color: var(--hover-blue);
    border-color: #fff;
    box-shadow: 0 0 0 2px var(--light-blue), 0 2px 8px rgba(74, 144, 226, 0.4);
}

.sidebar-btn .key-hint {
    position: absolute;
    top: 2px;
    right: 2px;
    font-size: 9px;
    padding: 1px 4px;
    background: rgba(255, 255, 255, 0.2);
    color: rgba(255, 255, 255, 0.85);
}

.sidebar-btn i {
    font-size: 20px;
}

.sidebar-btn span:not(.key-hint) {
    font-size: 10px;
    text-align: center;
    line-height: 1.2;
    word-break: break-word;
}

/* === Left Sidebar === */
.left-sidebar {
    width: 220px;
    flex-shrink: 0;
    background: #f8f9fa;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 12px;
    display: none;
    flex-direction: column;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.left-sidebar.is-visible {
    display: flex;
    animation: slideIn var(--transition-speed) ease-out;
}

@keyframes slideIn {
    from { opacity: 0; transform: translateX(-10px); }
    to { opacity: 1; transform: translateX(0); }
}

.left-panel-content {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.left-panel-content h3 {
    margin: 0 0 10px 0;
    color: var(--primary-blue);
    font-size: 14px;
    text-align: center;
    border-bottom: 2px solid var(--light-blue);
    padding-bottom: 8px;
}

.photo-button {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background: linear-gradient(135deg, #e8f4f8, #d4edda);
    border: 1px solid #a8d8b0;
    border-radius: 6px;
    color: #155724;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-speed);
    text-align: left;
}

.photo-button i {
    font-size: 12px;
    flex-shrink: 0;
}

.photo-button:hover {
    background: linear-gradient(135deg, #d4edda, #c3e6cb);
    border-color: #1e7e34;
    box-shadow: 0 2px 6px rgba(40, 167, 69, 0.2);
}

.photo-button.active {
    background: linear-gradient(135deg, #28a745, #20c997);
    color: white;
    border-color: #1e7e34;
}

.run-button {
    display: block;
    width: 100%;
    padding: 10px 12px;
    background: white;
    border: 1px solid var(--border-gray);
    border-radius: 6px;
    cursor: pointer;
    text-align: left;
    font-size: 12px;
    color: var(--text-dark);
    transition: all var(--transition-speed);
    position: relative;
}

.run-button:hover {
    background: var(--hover-blue);
    color: white;
    border-color: var(--primary-blue);
}

.run-button.active {
    background: var(--primary-blue);
    color: white;
    border-color: var(--primary-blue);
}

.run-button .key-hint {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
}

.run-button.active .key-hint {
    background: rgba(255, 255, 255, 0.2);
    color: rgba(255, 255, 255, 0.85);
}

.button-group {
    display: flex;
    gap: 4px;
}

.button-group .run-button:first-child {
    flex: 1;
}

.polar-btn {
    width: 36px !important;
    padding: 10px !important;
    display: flex !important;
    align-items: center;
    justify-content: center;
}

.polar-btn i {
    font-size: 14px;
}

/* === Bottom Panel === */
.bottom-panel {
    height: var(--bottom-height);
    background: linear-gradient(180deg, var(--panel-bg), #e0e0e0);
    border-top: 1px solid var(--border-gray);
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1600px;
    width: 100%;
    margin: 0 auto;
    padding: 0 20px;
}

.status-info {
    display: flex;
    gap: 20px;
}

.status-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--text-dark);
    font-weight: 400;
}

.status-item i {
    color: var(--text-light);
    font-size: 14px;
}

.status-item.connected i {
    color: var(--success-green);
}

.exit-btn {
    background: var(--primary-blue);
    color: white;
    border: none;
    padding: 6px 14px;
    cursor: pointer;
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 6px;
    border-radius: 4px;
    transition: all var(--transition-speed);
    font-weight: 500;
}

.exit-btn:hover {
    background: var(--hover-blue);
}

/* === Inline Notice (replaces modal) === */
.inline-notice {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    max-width: 600px;
    margin: 60px auto;
    padding: 24px;
    background: linear-gradient(135deg, #eef3ff, #f0f7ff);
    border: 1px solid #c5d5f0;
    border-left: 4px solid var(--light-blue);
    border-radius: 8px;
    animation: fadeIn var(--transition-speed) ease-out;
}

.inline-notice > i {
    font-size: 28px;
    color: var(--light-blue);
    flex-shrink: 0;
    margin-top: 2px;
}

.inline-notice-content h4 {
    color: var(--primary-blue);
    font-size: 16px;
    margin-bottom: 8px;
}

.inline-notice-content p {
    color: var(--text-dark);
    line-height: 1.6;
    margin-bottom: 14px;
}

.btn-switch-mode {
    background: var(--light-blue);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all var(--transition-speed);
}

.btn-switch-mode:hover {
    background: var(--primary-blue);
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(30, 58, 95, 0.3);
}

/* === Charts Container === */
.charts-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.chart-tabs {
    display: flex;
    justify-content: center;
    gap: 6px;
    padding: 0;
}

.chart-tab-btn {
    padding: 8px 20px;
    background: white;
    border: 1px solid var(--border-gray);
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-dark);
    transition: all var(--transition-speed);
}

.chart-tab-btn:hover {
    background: rgba(74, 144, 226, 0.1);
    border-color: var(--light-blue);
}

.chart-tab-btn.active {
    background: var(--primary-blue);
    color: white;
    border-color: var(--primary-blue);
}

/* === Modals === */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(3px);
}

.modal .modal-content {
    max-width: 90%;
    max-height: 90vh;
    margin: auto;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    border-radius: 8px;
}

.modal .close {
    position: fixed;
    top: 20px;
    right: 30px;
    color: white;
    font-size: 36px;
    cursor: pointer;
    z-index: 1001;
    transition: transform var(--transition-speed);
    background: none;
    border: none;
    padding: 0;
    line-height: 1;
    font-family: inherit;
}

.modal .close:hover {
    transform: scale(1.2);
}

.modal-caption {
    color: #fff;
    text-align: center;
    margin-top: 12px;
    max-width: 90vw;
    margin-left: auto;
    margin-right: auto;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* === HTML description styling === */
.screenshot-comment div strong {
    color: #2c3e50;
    font-weight: 600;
    display: block;
    margin: 10px 0 4px 0;
}

.screenshot-comment div em {
    color: #7f8c8d;
    font-style: italic;
    display: block;
    margin: 6px 0 4px 0;
    font-weight: 500;
}

.screenshot-comment div p {
    margin: 4px 0;
    line-height: 1.5;
}

.screenshot-comment div {
    line-height: 1.6;
}

/* === Step Progress Bar === */
.step-progress {
    max-width: 900px;
    margin: 0 auto 12px auto;
    padding: 12px 16px;
    background: linear-gradient(135deg, #f0f4ff, #e8f0fe);
    border: 1px solid #c5d5f0;
    border-radius: 8px;
}

.step-progress-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.step-progress-label {
    font-size: 13px;
    color: var(--text-light);
}

.step-progress-label strong {
    color: var(--primary-blue);
    font-size: 15px;
}

.step-progress-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--primary-blue);
}

.step-progress-bar {
    height: 6px;
    background: #dde4f0;
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 8px;
}

.step-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--light-blue), #2ecc71);
    border-radius: 3px;
    transition: width 0.4s ease;
}

.step-dots {
    display: flex;
    justify-content: center;
    gap: 4px;
}

.step-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #d0d8e8;
    cursor: pointer;
    transition: all var(--transition-speed);
    border: 2px solid transparent;
}

.step-dot:hover {
    background: var(--hover-blue);
    transform: scale(1.2);
}

.step-dot.active {
    background: var(--light-blue);
    border-color: var(--primary-blue);
    transform: scale(1.3);
}

.step-dot.completed {
    background: #2ecc71;
}

.step-dot.photo-dot {
    border-radius: 3px;
    width: 10px;
    height: 10px;
}

/* === Step Navigation Buttons === */
.step-navigation {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 900px;
    margin: 16px auto 0 auto;
    gap: 16px;
}

.step-nav-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 28px;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-speed);
}

.step-prev {
    background: #e8ecf2;
    color: var(--text-dark);
}

.step-prev:hover:not(:disabled) {
    background: #d0d8e8;
    transform: translateX(-2px);
}

.step-next {
    background: var(--light-blue);
    color: white;
    margin-left: auto;
}

.step-next:hover:not(:disabled) {
    background: var(--primary-blue);
    transform: translateX(2px);
    box-shadow: 0 3px 10px rgba(30, 58, 95, 0.3);
}

.step-finish {
    background: #2ecc71 !important;
}

.step-finish:hover:not(:disabled) {
    background: #27ae60 !important;
    box-shadow: 0 3px 10px rgba(39, 174, 96, 0.4);
}

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

/* Left sidebar step numbers */
.step-number-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--border-gray);
    color: white;
    font-size: 10px;
    font-weight: 700;
    flex-shrink: 0;
    margin-right: 4px;
    transition: background var(--transition-speed);
}

.run-button.active .step-number-badge,
.photo-button.active .step-number-badge {
    background: white;
    color: var(--primary-blue);
}

.photo-button .step-number-badge {
    background: #1e7e34;
}

/* === Responsive === */
@media (max-width: 1024px) {
    .main-layout {
        padding: 10px;
        gap: 8px;
    }

    .right-sidebar {
        width: 80px;
    }

    .sidebar-btn span:not(.key-hint) {
        font-size: 9px;
    }

    .left-sidebar {
        width: 190px;
    }

    /* Hide left sidebar on tablet, rely on progress bar + Back/Next */
    .left-sidebar.is-visible {
        display: none;
    }

    .step-dots {
        gap: 4px;
    }

    .step-dot {
        width: 12px;
        height: 12px;
    }
}

@media (max-width: 768px) {
    .top-tabs {
        padding: 0;
        overflow-x: auto;
    }

    .top-tabs {
        height: 46px;
        padding: 0 40px 0 4px;
        justify-content: flex-start;
    }

    .tab-button {
        padding: 6px 10px;
        font-size: 11px;
        gap: 3px;
        flex: 1;
        justify-content: center;
    }

    .tab-button .key-hint {
        display: none;
    }

    .lang-selector {
        right: 4px;
    }

    .lang-toggle {
        padding: 4px 6px;
        font-size: 14px;
    }

    .lang-arrow {
        display: none;
    }

    .main-layout {
        flex-direction: column;
        padding: 8px;
    }

    .left-sidebar {
        width: 100%;
        flex-direction: row;
        overflow-x: auto;
    }

    /* Hide left sidebar entirely on mobile for balancing */
    .left-sidebar.is-visible {
        display: none;
    }

    .right-sidebar {
        width: 100%;
        flex-direction: row;
        padding: 6px;
        overflow-x: auto;
        flex-wrap: nowrap;
    }

    .sidebar-btn {
        min-width: 60px;
        flex-shrink: 0;
    }

    .sidebar-btn span:not(.key-hint) {
        font-size: 8px;
    }

    .sidebar-btn i {
        font-size: 16px;
    }

    .screen-container {
        aspect-ratio: auto;
        max-height: 50vh;
    }

    .bottom-panel {
        height: auto;
        padding: 8px 12px;
        flex-wrap: wrap;
        gap: 8px;
    }

    .status-info {
        flex-wrap: wrap;
        gap: 10px;
    }

    .inline-notice {
        margin: 20px auto;
        padding: 16px;
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    /* Step dots: replace with compact numbered indicator on mobile */
    .step-dots {
        display: none;
    }

    .step-progress {
        padding: 8px 12px;
    }

    .step-nav-btn {
        padding: 10px 20px;
        font-size: 14px;
    }

    .step-navigation {
        padding: 8px 0;
    }
}
