/*
 * ScanToServer - Main Stylesheet
 * MIT License
 */

/* CSS Variables */
:root {
    --primary-color: #2d6a2d;
    --primary-dark: #1e4d1e;
    --success-color: #4CAF50;
    --error-color: #F44336;
    --warning-color: #FF9800;
    --background: #1e1e1e;
    --surface: #2a2a2a;
    --section-bg: #333333;
    --text-primary: #e8e8e8;
    --text-secondary: #a8a8a8;
    --border-color: #444444;
    --shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 8px 16px rgba(0, 0, 0, 0.5);
}

/* Reset & Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    width: 100%;
    height: auto;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--background);
    color: var(--text-primary);
    overflow: auto;
}

body {
    display: flex;
    flex-direction: column;
}

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

/* Header */
.app-header {
    background-color: var(--primary-color);
    color: white;
    padding: 1rem;
    box-shadow: var(--shadow);
    flex-shrink: 0;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 680px;
    margin: 0 auto;
    width: 100%;
}

.app-title {
    font-size: 1.5rem;
    font-weight: 600;
    margin: 0;
}

.gear-icon {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: white;
    padding: 0.5rem;
    border-radius: 3px;
    transition: background-color 0.2s ease;
}

.gear-icon:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

/* Main Content */
.app-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 1rem;
    max-width: 680px;
    margin: 0 auto;
    width: 100%;
    gap: 1rem;
    background-color: var(--surface);
}

/* Session Info - Hidden, count now in history header */
.session-info {
    display: none;
}

/* Result Box */
.result-box {
    padding: 1.5rem;
    background-color: var(--section-bg);
    border-radius: 4px;
    min-height: 80px;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.3s ease;
    overflow: hidden;
    color: #1a1a1a;
}

.result-box.success {
    background-color: #E8F5E9;
}

.result-box.error {
    background-color: #FFEBEE;
}

.result-placeholder {
    text-align: center;
    color: #1a1a1a;
}

.result-content {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    width: 100%;
    color: #1a1a1a;
}

.result-content .result-label {
    font-size: 0.875rem;
    color: #1a1a1a;
}

.result-content .result-value {
    font-size: 1.25rem;
    font-weight: 600;
    font-family: 'Courier New', monospace;
    word-break: break-all;
    color: #1a1a1a;
}

.result-content .result-status {
    font-size: 0.875rem;
    padding: 0.5rem;
    border-radius: 3px;
    text-align: center;
    background-color: rgba(0, 0, 0, 0.05);
    color: #1a1a1a;
}

.result-content .result-status.valid {
    background-color: #C8E6C9;
    color: #2E7D32;
}

.result-content .result-status.invalid {
    background-color: #FFCDD2;
    color: #C62828;
}

/* Scan Actions - 3-column flex row */
.scan-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    background-color: var(--section-bg);
    padding: 1rem;
    border-radius: 4px;
}

.btn-scan {
    flex: 1;
    padding: 1.5rem 1rem;
    border: none;
    border-radius: 3px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    box-shadow: var(--shadow);
    background-color: var(--primary-color);
    color: white;
}

.btn-scan:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn-scan:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-icon {
    font-size: 1.75rem;
}

.btn-label {
    font-size: 0.875rem;
}

/* Continuous Scan Checkbox - Centered between buttons */
.continuous-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
    font-size: 12px;
}

.continuous-scan-label {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    user-select: none;
}

.continuous-scan-label .checkbox-input {
    width: 20px;
    height: 20px;
    cursor: pointer;
    accent-color: var(--primary-color);
}

/* History Section */
.history-section {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    background-color: var(--section-bg);
    padding: 1rem;
    border-radius: 4px;
}

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

.history-header-left {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.history-header h2 {
    font-size: 1.1rem;
    margin: 0;
}

.btn-copy {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.25rem;
    transition: opacity 0.2s ease;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
}

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

.btn-copy:hover {
    opacity: 0.7;
}

.btn-reset {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border-color);
    background-color: var(--section-bg);
    border-radius: 3px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    color: var(--text-primary);
}

.btn-reset:hover {
    background-color: var(--border-color);
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    overflow-y: auto;
    max-height: 200px;
}

/* History layout - high density, one line */
.history-item {
    padding: 4px 0.75rem;
    background-color: #3a3a3a;
    border-radius: 4px;
    border-left: 4px solid var(--primary-color);
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.history-item.success {
    border-left-color: var(--success-color);
}

.history-item.error {
    border-left-color: var(--error-color);
}

.history-item-value {
    flex: 0 0 auto;
    font-size: 0.95rem;
    font-weight: 600;
    font-family: 'Courier New', monospace;
    word-break: break-all;
    min-width: 80px;
}

.history-item.error .history-item-value {
    color: var(--text-secondary);
    font-weight: normal;
}

.history-item-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex: 1;
}

.history-item-time {
    font-size: 0.75rem;
    color: var(--text-secondary);
    white-space: nowrap;
}

.history-item-meta {
    font-size: 0.75rem;
    color: var(--text-secondary);
    display: flex;
    gap: 0.5rem;
    margin-left: auto;
    white-space: nowrap;
}

.empty-message {
    text-align: center;
    color: var(--text-secondary);
    padding: 1rem;
    font-size: 0.9rem;
}

/* Collapsible Settings Section */
.settings-collapsible-section {
    display: flex;
    flex-direction: column;
    gap: 0;
    background-color: var(--section-bg);
    border-radius: 4px;
    overflow: hidden;
}

.settings-collapsible-header {
    padding: 1rem;
    cursor: pointer;
    user-select: none;
    transition: background-color 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.settings-collapsible-header:hover {
    background-color: #3a3a3a;
}

.settings-header-content {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    min-width: 0;
}

.settings-chevron {
    font-size: 0.85rem;
    color: var(--text-secondary);
    transition: transform 0.2s ease;
    flex-shrink: 0;
}

.settings-collapsible-header.expanded .settings-chevron {
    transform: rotate(180deg);
}

.settings-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    flex-shrink: 0;
}

.settings-summary-inline {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
    color: var(--text-secondary);
    min-width: 0;
    flex: 1;
    overflow: hidden;
}

.summary-item {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.summary-sep {
    flex-shrink: 0;
    color: var(--text-secondary);
}

.settings-collapsible-content {
    display: flex;
    flex-direction: column;
    gap: 0;
    padding: 1rem;
    border-top: 1px solid var(--border-color);
    max-height: 600px;
    overflow-y: auto;
}

.settings-collapsible-content.expanded {
    display: flex;
}

/* Settings Action Buttons */
.settings-actions {
    display: flex;
    gap: 0.75rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
    margin-top: 0.5rem;
}

/* Settings Groups */
.settings-group {
    margin-bottom: 1.5rem;
    background-color: #3a3a3a;
    padding: 1rem;
    border-radius: 4px;
}

.settings-collapsible-content .settings-group {
    background-color: transparent;
    padding: 0;
    margin-bottom: 1.5rem;
    border-radius: 0;
}

.settings-group:last-of-type {
    margin-bottom: 1rem;
}

.settings-group h3 {
    font-size: 1rem;
    font-weight: 600;
    margin: 0 0 1rem 0;
    color: var(--text-primary);
}

/* Form Elements */
.form-group {
    margin-bottom: 1rem;
}

.form-group:last-child {
    margin-bottom: 0;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    font-size: 0.95rem;
    color: var(--text-primary);
}

.form-hint {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
}

.text-input,
.select-input,
textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 3px;
    font-size: 1rem;
    font-family: inherit;
    transition: border-color 0.2s ease;
    background-color: #2a2a2a;
    color: var(--text-primary);
}

.text-input:focus,
.select-input:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(45, 106, 45, 0.1);
}

textarea {
    resize: vertical;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 0;
    cursor: pointer;
    user-select: none;
}

.checkbox-input {
    width: 20px;
    height: 20px;
    cursor: pointer;
    accent-color: var(--primary-color);
}

.time-format-options {
    display: flex;
    gap: 1.5rem;
    align-items: center;
    margin-top: 0.5rem;
}

.radio-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    user-select: none;
}

.radio-label input[type="radio"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--primary-color);
}

/* Buttons */
.btn {
    padding: 0.75rem 1rem;
    border: none;
    border-radius: 3px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background-color: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-lg);
}

.btn-secondary {
    background-color: var(--background);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover:not(:disabled) {
    background-color: var(--border-color);
    transform: translateY(-1px);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.profile-selector {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.profile-selector > div {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
}

.settings-collapsible-content .profile-selector {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
}

/* Settings Footer */
.settings-footer {
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.85rem;
    padding: 1rem;
    background-color: transparent !important;
    border-top: 1px solid var(--border-color);
    margin-top: 1rem;
    padding-top: 1.5rem;
    background-color: var(--surface) !important;
}

.settings-footer a {
    color: var(--primary-color);
    text-decoration: none;
    transition: color 0.2s ease;
}

.settings-footer a:hover {
    color: var(--primary-dark);
    text-decoration: underline;
}

.settings-footer p {
    margin: 0.5rem 0;
}

/* Business Pitch Panel */
.business-pitch {
    margin-top: 1rem;
    padding: 1.5rem;
    background-color: rgba(45, 106, 45, 0.08);
    border-radius: 4px;
    border-left: 4px solid var(--primary-color);
    font-size: 0.95rem;
}

.pitch-heading {
    color: var(--primary-color);
    font-size: 1.2rem;
    font-weight: 600;
    margin: 0 0 0.75rem 0;
}

.pitch-intro {
    color: var(--text-primary);
    font-size: 0.95rem;
    line-height: 1.5;
    margin: 0 0 1rem 0;
}

.pitch-bullets {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.pitch-bullets li {
    color: var(--text-primary);
    font-size: 0.9rem;
    line-height: 1.4;
    padding-left: 1.25rem;
    position: relative;
}

.pitch-bullets li:before {
    content: '·';
    position: absolute;
    left: 0;
    color: var(--primary-color);
    font-weight: bold;
    font-size: 1.2rem;
}

/* QR Code Panel */
.qr-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    margin: 1rem 0;
    padding: 1rem;
    background-color: #252525;
    border-radius: 4px;
}

.qr-code-container {
    display: flex;
    align-items: center;
    justify-content: center;
}

.qr-code-container canvas {
    max-width: 128px;
    height: auto;
}

.qr-caption {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin: 0;
    text-align: center;
    font-weight: 500;
}

/* Pricing / Plans Footer */
.pricing-footer {
    margin-top: 1rem;
    padding: 1.5rem;
    background-color: #252525;
    border-radius: 4px;
    border-top: 1px solid var(--border-color);
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.pricing-header {
    text-align: center;
    margin-bottom: 1.25rem;
    font-size: 0.8rem;
    color: var(--text-secondary);
    letter-spacing: 0.05em;
}

/* Pricing Table */
.pricing-table-wrapper {
    overflow-x: auto;
    margin-bottom: 1rem;
}

.pricing-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.pricing-table thead {
    background-color: #3a3a3a;
}

.pricing-table th {
    padding: 1rem 0.75rem;
    text-align: center;
    font-weight: 600;
    color: var(--text-primary);
    border-bottom: 2px solid var(--border-color);
    font-size: 0.95rem;
}

.pricing-table th:first-child {
    text-align: left;
}

.pricing-table tbody tr {
    border-bottom: 1px solid var(--border-color);
}

.pricing-table tbody tr:nth-child(even) {
    background-color: rgba(58, 58, 58, 0.5);
}

.pricing-table td {
    padding: 0.75rem;
    text-align: center;
    color: var(--text-primary);
}

.pricing-table td:first-child {
    text-align: left;
    font-weight: 500;
    color: var(--text-primary);
}

.pricing-table .feature-name {
    font-weight: 500;
    color: var(--text-primary);
    text-align: left;
}

.pricing-table .icon-check {
    color: #2d6a2d;
    font-weight: bold;
    font-size: 1.2rem;
}

.pricing-table .icon-cross {
    color: #666666;
    font-weight: bold;
    font-size: 1.2rem;
}

.pricing-footer-text {
    text-align: center;
    margin: 1rem 0;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.pricing-footer-text p {
    margin: 0.5rem 0;
}

.pricing-cta {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    align-items: center;
    margin-top: 1rem;
}

.btn-cta-primary {
    padding: 0.6rem 1rem;
    background-color: #2d6a2d;
    color: white;
    border: none;
    border-radius: 3px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-cta-primary:hover {
    background-color: #1e4d1e;
    transform: translateY(-1px);
}

.btn-cta-link {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.85rem;
    transition: color 0.2s ease;
}

.btn-cta-link:hover {
    color: var(--text-primary);
    text-decoration: underline;
}

/* Validation Result */
.validation-result {
    padding: 1rem;
    border-radius: 4px;
    font-weight: 500;
    transition: opacity 0.3s ease;
    position: fixed;
    bottom: 1rem;
    left: 1rem;
    right: 1rem;
    max-width: 650px;
    margin: 0 auto;
}

.validation-result.hidden {
    display: none;
}

.validation-result.valid {
    background-color: #C8E6C9;
    color: #2E7D32;
}

.validation-result.invalid {
    background-color: #FFCDD2;
    color: #C62828;
}

/* Inline Camera Preview */
.inline-camera {
    width: 100%;
    height: 240px;
    background-color: #000;
    border-radius: 4px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.inline-camera.hidden {
    display: none !important;
}

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

/* Context Info */
.context-info {
    padding: 1rem;
    background-color: rgba(45, 106, 45, 0.15);
    border-radius: 4px;
    border-left: 4px solid var(--primary-color);
    font-size: 0.9rem;
    color: var(--text-primary);
}

.context-info p {
    margin: 0.5rem 0;
    line-height: 1.4;
}

.context-info p:first-child {
    margin-top: 0;
    font-weight: 500;
}

.context-info p:last-child {
    margin-bottom: 0;
}

/* Scanning active state for toggle buttons */
.btn-scan.scanning {
    background-color: #8b0000;
    box-shadow: 0 0 0 3px rgba(139, 0, 0, 0.4);
    animation: pulse 1.4s ease-in-out infinite;
}

.btn-scan.scanning:hover:not(:disabled) {
    background-color: #a00000;
    transform: none;
}

/* Animations */
@keyframes pulse {
    0%, 100% { box-shadow: 0 0 0 3px rgba(139, 0, 0, 0.4); }
    50% { box-shadow: 0 0 0 8px rgba(139, 0, 0, 0); }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

@keyframes flash {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

.error-shake {
    animation: shake 0.4s ease-in-out;
}

.success-flash {
    animation: flash 0.6s ease-in-out;
}

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

.loading {
    opacity: 0.7;
    pointer-events: none;
}

/* Responsive Design */
@media (max-width: 680px) {
    .app-main {
        padding: 0.75rem;
        gap: 0.75rem;
    }

    .scan-actions {
        gap: 8px;
        padding: 0.75rem;
    }

    .btn-scan {
        padding: 1.25rem 0.75rem;
    }

    .history-list {
        max-height: 180px;
    }

    .settings-panel {
        max-width: 100%;
    }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
