/* HAADF-STEM Web GUI - Qt-accurate Styles */

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(180deg, #2c3e50 0%, #1a252f 100%);
    color: #ecf0f1;
    overflow: hidden;
    height: 100vh;
}

.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

/* Header */
.app-header {
    background: linear-gradient(90deg, #4361ee 0%, #3f37c9 100%);
    padding: 12px 20px;
    border-bottom: 2px solid #34495e;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.app-title {
    font-size: 20px;
    font-weight: 700;
    color: white;
    display: flex;
    align-items: center;
    gap: 8px;
}

.title-icon {
    font-size: 24px;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 20px;
}

/* User Info Styles */
.user-info {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 8px 15px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    backdrop-filter: blur(10px);
}

.user-details {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: white;
    font-weight: 500;
}

.user-details .clickable {
    cursor: pointer;
    transition: opacity 0.2s;
}

.user-details .clickable:hover {
    opacity: 0.8;
    text-decoration: underline;
}

.user-icon {
    font-size: 18px;
}

.separator {
    color: rgba(255, 255, 255, 0.5);
}

.membership-badge {
    padding: 2px 8px;
    background: linear-gradient(135deg, #ffd700 0%, #ffed4e 100%);
    color: #333;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 700;
}

.balance-info {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 6px;
    font-size: 13px;
    color: white;
}

.balance-icon {
    font-size: 16px;
}

.balance-amount {
    font-weight: 700;
    font-size: 14px;
    color: #ffd700;
}

.balance-unit {
    font-size: 12px;
    opacity: 0.9;
}

.icon-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 14px;
    padding: 2px;
    opacity: 0.7;
    transition: opacity 0.2s, transform 0.2s;
}

.icon-btn:hover {
    opacity: 1;
    transform: scale(1.1);
}

.logout-btn {
    padding: 6px 14px;
    background: rgba(231, 76, 60, 0.8);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.logout-btn:hover {
    background: rgba(231, 76, 60, 1);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(231, 76, 60, 0.4);
}

.theme-selector {
    display: flex;
    align-items: center;
    gap: 8px;
}

.theme-selector label {
    font-size: 12px;
    font-weight: 600;
    color: white;
}

.theme-selector select {
    padding: 6px 12px;
    border: 2px solid #34495e;
    border-radius: 6px;
    background: #2c3e50;
    color: #ecf0f1;
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
}

.theme-selector select:focus {
    outline: none;
    border-color: #4361ee;
    background: #1a252f;
}

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

/* Left Panel - Controls */
.left-panel {
    width: 400px;
    min-width: 400px;
    background: #2c3e50;
    border-right: 2px solid #34495e;
    overflow-y: auto;
    flex-shrink: 0;
}

.control-scroll {
    padding: 16px;
}

/* Control Sections */
.control-section {
    background: linear-gradient(180deg, #34495e 0%, #2c3e50 100%);
    border: 2px solid #34495e;
    border-radius: 8px;
    margin-bottom: 16px;
    padding: 16px;
    position: relative;
}

.control-section::before {
    content: attr(data-title);
    position: absolute;
    top: -12px;
    left: 12px;
    padding: 5px 12px;
    background: linear-gradient(90deg, #4361ee 0%, #3f37c9 100%);
    color: white;
    border-radius: 15px;
    font-weight: 600;
    font-size: 11px;
}

.section-title {
    font-weight: 600;
    font-size: 11pt;
    color: #ecf0f1;
    margin-bottom: 12px;
    padding: 8px 12px;
    background: linear-gradient(90deg, #4361ee 0%, #3f37c9 100%);
    border-radius: 4px;
    color: white;
}

/* Control Grid */
.control-grid {
    display: grid;
    gap: 12px;
}

.control-grid.aberration-grid {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.control-group label {
    font-size: 10pt;
    font-weight: 600;
    color: #ecf0f1;
}

/* Input Fields */
input[type="text"],
input[type="number"],
select {
    border: 2px solid #34495e;
    border-radius: 6px;
    padding: 8px 12px;
    background: #2c3e50;
    font-size: 11pt;
    color: #ecf0f1;
    font-weight: 500;
    transition: all 0.2s ease;
}

input[type="text"]:focus,
input[type="number"]:focus,
select:focus {
    border-color: #4361ee;
    outline: none;
    background: #1a252f;
}

input[type="text"]:disabled,
input[type="number"]:disabled {
    background: #34495e;
    color: #7f8c8d;
    cursor: not-allowed;
}

.number-input {
    width: 100%;
}

.file-input {
    flex: 1;
}

.input-with-button {
    display: flex;
    gap: 8px;
    align-items: center;
}

/* Buttons */
.browse-btn {
    background: linear-gradient(90deg, #06ffa5 0%, #00b4d8 50%, #0077b6 100%);
    color: white;
    border: none;
    border-radius: 4px;
    padding: 8px 16px;
    font-size: 10px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    max-width: 80px;
}

.browse-btn:hover {
    background: linear-gradient(90deg, #00b4d8 0%, #0077b6 100%);
    transform: translateY(-1px);
}

.manual-btn {
    background: linear-gradient(180deg, #9f7aea 0%, #805ad5 100%);
    color: white;
    border: none;
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 8pt;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    max-width: 80px;
}

.manual-btn:hover {
    background: linear-gradient(180deg, #b794f4 0%, #9f7aea 100%);
}

/* Pixel Size Container */
.pixel-size-container {
    display: flex;
    gap: 8px;
    align-items: center;
}

.pixel-info {
    font-size: 9pt;
    font-style: italic;
    color: #9f7aea;
    margin-top: 4px;
}

.unit {
    font-size: 9pt;
    color: #bdc3c7;
    margin-left: 4px;
}

/* Algorithm Selection */
.algorithm-selection {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.radio-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.radio-option {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    background: #2c3e50;
    border: 2px solid #34495e;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.radio-option:hover {
    background: #34495e;
    border-color: #4361ee;
}

.radio-option input[type="radio"] {
    margin-right: 12px;
    width: 16px;
    height: 16px;
    accent-color: #4361ee;
}

.radio-label {
    font-size: 10pt;
    font-weight: 600;
    color: #ecf0f1;
}

/* Checkboxes */
.checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.checkbox-option {
    display: flex;
    align-items: center;
    padding: 8px 0;
}

.checkbox-option input[type="checkbox"] {
    width: 20px;
    height: 20px;
    margin-right: 12px;
    accent-color: #4361ee;
}

.checkbox-label {
    font-size: 10pt;
    font-weight: 600;
    color: #ecf0f1;
}

/* Button Groups */
.button-group {
    display: flex;
    gap: 8px;
    justify-content: stretch;
}

.btn {
    flex: 1;
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    font-size: 10pt;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
}

.btn-primary {
    background: linear-gradient(180deg, #9f7aea 0%, #805ad5 100%);
    color: white;
}

.btn-primary:hover {
    background: linear-gradient(180deg, #b794f4 0%, #9f7aea 100%);
    transform: translateY(-1px);
}

.btn-primary:disabled {
    background: #7f8c8d;
    color: #bdc3c7;
    cursor: not-allowed;
    transform: none;
}

.btn-success {
    background: #2196F3;
    color: white;
}

.btn-success:hover {
    background: #1976D2;
    transform: translateY(-1px);
}

.btn-success:disabled {
    background: #7f8c8d;
    color: #bdc3c7;
    cursor: not-allowed;
    transform: none;
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #5a6268;
    transform: translateY(-1px);
}

.btn-secondary:disabled {
    background: #7f8c8d;
    color: #bdc3c7;
    cursor: not-allowed;
    transform: none;
}

/* Progress Bar */
.progress-container {
    display: flex;
    align-items: center;
    gap: 12px;
}

.progress-bar {
    flex: 1;
    height: 24px;
    border: 2px solid #34495e;
    border-radius: 6px;
    background: #2c3e50;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #06ffa5 0%, #00b4d8 50%, #0077b6 100%);
    border-radius: 4px;
    width: 0%;
    transition: width 0.3s ease;
}

.progress-text {
    font-weight: 600;
    font-size: 10pt;
    color: white;
    min-width: 40px;
    text-align: center;
}

/* Status Text */
.status-container {
    height: 100px;
}

.status-text {
    width: 100%;
    height: 100%;
    border: 2px solid #34495e;
    border-radius: 6px;
    background: #1a252f;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 10pt;
    color: #ecf0f1;
    padding: 8px 12px;
    resize: none;
}

/* Right Panel - Image Display */
.right-panel {
    flex: 1;
    background: #2c3e50;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.display-tabs {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.tab-headers {
    display: flex;
    background: #34495e;
    border-bottom: 2px solid #2c3e50;
}

.tab-header {
    flex: 1;
    padding: 12px 16px;
    background: none;
    border: none;
    color: #bdc3c7;
    font-size: 11pt;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    border-bottom: 3px solid transparent;
}

.tab-header:hover {
    background: #3a4a5c;
    color: #ecf0f1;
}

.tab-header.active {
    background: #4361ee;
    color: white;
    border-bottom-color: #3f37c9;
}

.tab-content {
    flex: 1;
    display: none;
    flex-direction: column;
    overflow: hidden;
}

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

/* Display Controls */
.display-controls {
    padding: 12px 16px;
    background: #34495e;
    border-bottom: 1px solid #2c3e50;
}

.control-row {
    display: flex;
    gap: 16px;
    align-items: center;
    flex-wrap: wrap;
}

.control-row label {
    font-size: 10pt;
    font-weight: 600;
    color: #ecf0f1;
    white-space: nowrap;
}

.control-row select {
    min-width: 120px;
}

/* Image Container */
.image-container {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #1a252f;
    margin: 16px;
    border: 2px solid #34495e;
    border-radius: 6px;
    overflow: hidden;
}

.image-canvas {
    max-width: 100%;
    max-height: 100%;
    display: block;
}

.image-placeholder {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: #7f8c8d;
    font-size: 14pt;
    font-weight: 500;
}

.image-placeholder::before {
    content: "📷";
    display: block;
    font-size: 48px;
    margin-bottom: 12px;
    opacity: 0.5;
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.loading-overlay.active {
    display: flex;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #34495e;
    border-top: 4px solid #4361ee;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.loading-text {
    margin-top: 16px;
    font-size: 14pt;
    font-weight: 600;
    color: white;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

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

::-webkit-scrollbar-track {
    background: #2c3e50;
    border-radius: 6px;
}

::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, #34495e 0%, #7f8c8d 100%);
    border-radius: 6px;
    min-height: 20px;
}

::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, #4361ee 0%, #3f37c9 100%);
}

/* Theme Variations */

/* Professional Blue Theme (Default) */
body.professional-blue {
    background: linear-gradient(180deg, #2c3e50 0%, #1a252f 100%);
}

body.professional-blue .control-section {
    background: linear-gradient(180deg, #34495e 0%, #2c3e50 100%);
    border-color: #34495e;
}

body.professional-blue .section-title {
    background: linear-gradient(90deg, #4361ee 0%, #3f37c9 100%);
}

body.professional-blue .btn-primary {
    background: linear-gradient(180deg, #4361ee 0%, #3f37c9 100%);
}

body.professional-blue .progress-fill {
    background: linear-gradient(90deg, #06ffa5 0%, #00b4d8 50%, #0077b6 100%);
}

/* Dark Mode Theme */
body.dark-mode {
    background: linear-gradient(180deg, #2d3748 0%, #1a202c 100%);
}

body.dark-mode .control-section {
    background: linear-gradient(180deg, #4a5568 0%, #2d3748 100%);
    border-color: #4a5568;
}

body.dark-mode .section-title {
    background: linear-gradient(90deg, #9f7aea 0%, #805ad5 100%);
}

body.dark-mode .btn-primary {
    background: linear-gradient(180deg, #9f7aea 0%, #805ad5 100%);
}

body.dark-mode .progress-fill {
    background: linear-gradient(90deg, #4fd1c5 0%, #38b2ac 50%, #319795 100%);
}

/* Light Clean Theme */
body.light-clean {
    background: linear-gradient(180deg, #37474f 0%, #263238 100%);
}

body.light-clean .control-section {
    background: linear-gradient(180deg, #455a64 0%, #37474f 100%);
    border-color: #455a64;
}

body.light-clean .section-title {
    background: linear-gradient(90deg, #2196f3 0%, #1976d2 100%);
}

body.light-clean .btn-primary {
    background: linear-gradient(180deg, #2196f3 0%, #1976d2 100%);
}

body.light-clean .progress-fill {
    background: linear-gradient(90deg, #66bb6a 0%, #4caf50 100%);
}

/* Nature Green Theme */
body.nature-green {
    background: linear-gradient(180deg, #1b5e20 0%, #0d2818 100%);
}

body.nature-green .control-section {
    background: linear-gradient(180deg, #2e7d32 0%, #1b5e20 100%);
    border-color: #2e7d32;
}

body.nature-green .section-title {
    background: linear-gradient(90deg, #66bb6a 0%, #4caf50 100%);
}

body.nature-green .btn-primary {
    background: linear-gradient(180deg, #66bb6a 0%, #4caf50 100%);
}

body.nature-green .progress-fill {
    background: linear-gradient(90deg, #26a69a 0%, #00897b 50%, #00695c 100%);
}

/* Sunset Orange Theme */
body.sunset-orange {
    background: linear-gradient(180deg, #e65100 0%, #bf360c 100%);
}

body.sunset-orange .control-section {
    background: linear-gradient(180deg, #f57c00 0%, #e65100 100%);
    border-color: #f57c00;
}

body.sunset-orange .section-title {
    background: linear-gradient(90deg, #ff9800 0%, #f57c00 100%);
}

body.sunset-orange .btn-primary {
    background: linear-gradient(180deg, #ff9800 0%, #f57c00 100%);
}

body.sunset-orange .progress-fill {
    background: linear-gradient(90deg, #ef5350 0%, #f44336 50%, #d32f2f 100%);
}

/* Responsive Design */
@media (max-width: 1200px) {
    .left-panel {
        width: 350px;
        min-width: 350px;
    }
}

@media (max-width: 900px) {
    .main-content {
        flex-direction: column;
    }
    
    .left-panel {
        width: 100%;
        min-width: unset;
        height: 50vh;
        border-right: none;
        border-bottom: 2px solid #34495e;
    }
    
    .right-panel {
        height: 50vh;
    }
    
    .control-row {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }
    
    .control-row label {
        margin-bottom: 4px;
    }
}