/* ==================== Reset & Base Styles ==================== */
:root {
    --primary: #1e90ff;
    --primary-dark: #1873cc;
    --secondary: #6c757d;
    --success: #28a745;
    --danger: #dc3545;
    --warning: #ffc107;
    --dark: #1a1a1a;
    --light: #f8f9fa;
    --border: #e0e0e0;
    --text: #2c2c2c;
    --text-light: #6c757d;
    --radius: 8px;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.15);
}

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

html, body {
    height: 100%;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    color: var(--text);
    background: #f5f5f5;
}

/* ==================== Layout ==================== */
.scenery-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    background: #f5f5f5;
}

.scenery-header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    padding: 24px;
    box-shadow: var(--shadow-lg);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-content h1 {
    font-size: 28px;
    margin-bottom: 4px;
}

.header-content p {
    font-size: 14px;
    opacity: 0.9;
}

.header-nav {
    display: flex;
    gap: 12px;
    align-items: center;
}

.header-auth-status {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.16);
    color: white;
    font-size: 14px;
}

.header-auth-status .btn {
    padding: 6px 12px;
}

.header-auth-status a {
    color: white;
}

.scenery-main {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

/* ==================== Navigation Tabs ==================== */
.nav-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
    border-bottom: 2px solid var(--border);
    flex-wrap: wrap;
}

.nav-tab {
    padding: 12px 20px;
    border: none;
    background: transparent;
    color: var(--text-light);
    font-size: 16px;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    transition: all 0.3s ease;
    font-weight: 500;
}

.nav-tab:hover {
    color: var(--primary);
}

.nav-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.nav-tab .icon {
    margin-right: 8px;
}

.generation-status {
    display: none;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
    padding: 12px 16px;
    border-radius: var(--radius);
    background: linear-gradient(135deg, rgba(30, 144, 255, 0.1) 0%, rgba(24, 115, 204, 0.16) 100%);
    border: 1px solid rgba(30, 144, 255, 0.22);
    color: var(--primary-dark);
    box-shadow: var(--shadow);
    font-weight: 600;
}

.generation-status.active {
    display: flex;
}

.generation-controls {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 20px;
}

.generation-model-picker {
    display: flex;
    align-items: center;
    gap: 10px;
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px 14px;
    box-shadow: var(--shadow);
}

.generation-model-picker label {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
}

.generation-model-picker select {
    min-width: 220px;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: white;
    color: var(--text);
    font-size: 14px;
}

.generation-model-picker select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(30, 144, 255, 0.1);
}

.generation-status-spinner {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 2px solid rgba(30, 144, 255, 0.2);
    border-top-color: var(--primary);
    animation: scenery-spin 0.8s linear infinite;
    flex: 0 0 auto;
}

@keyframes scenery-spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

/* ==================== Tab Content ==================== */
.tab-pane {
    display: none;
    animation: fadeIn 0.3s ease;
}

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

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* ==================== Editor Layout ==================== */
.scenery-editor-container {
    display: grid;
    grid-template-columns: 1fr 350px;
    gap: 24px;
    margin-bottom: 24px;
}

@media (max-width: 1200px) {
    .scenery-editor-container {
        grid-template-columns: 1fr;
    }
    
    .preview-panel {
        grid-row: 1;
    }
}

/* ==================== Form Styles ==================== */
.scenery-form {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.form-section {
    background: white;
    padding: 20px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.form-section h2 {
    font-size: 18px;
    margin-bottom: 16px;
    color: var(--primary);
    border-bottom: 2px solid var(--primary);
    padding-bottom: 8px;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.section-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.form-group {
    display: flex;
    flex-direction: column;
    margin-bottom: 16px;
}

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

.form-group label {
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text);
    font-size: 14px;
}

.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="number"],
.form-group textarea,
.form-group select {
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 14px;
    font-family: inherit;
    transition: all 0.3s ease;
}

.form-group input[type="text"]:focus,
.form-group input[type="email"]:focus,
.form-group input[type="number"]:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(30, 144, 255, 0.1);
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

@media (max-width: 768px) {
    .form-row {
        grid-template-columns: 1fr;
    }
}

.form-group input[type="checkbox"] {
    margin-right: 8px;
    cursor: pointer;
    width: 18px;
    height: 18px;
}

/* ==================== Buttons ==================== */
.btn {
    padding: 10px 16px;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

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

.btn-primary:hover {
    background: var(--primary-dark);
    box-shadow: var(--shadow);
}

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

.btn-secondary:hover {
    background: #5a6268;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
}

.btn-lg {
    padding: 12px 24px;
    font-size: 16px;
}

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

.btn-danger:hover {
    background: #c82333;
}

.btn:disabled,
.btn.is-loading {
    opacity: 0.72;
    cursor: wait;
    box-shadow: none;
}

.btn.is-loading {
    position: relative;
}

.btn.is-loading::after {
    content: "";
    width: 12px;
    height: 12px;
    margin-left: 4px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.35);
    border-top-color: rgba(255, 255, 255, 0.95);
    animation: scenery-spin 0.8s linear infinite;
}

/* ==================== Form Actions ==================== */
.form-actions {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 12px;
    margin-top: 24px;
}

@media (max-width: 768px) {
    .form-actions {
        grid-template-columns: 1fr;
    }
}

/* ==================== Item Cards ==================== */
.items-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.item-card {
    background: #f9f9f9;
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 16px;
    transition: all 0.3s ease;
}

.item-card:hover {
    box-shadow: var(--shadow);
    border-color: var(--primary);
}

.item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.item-header h4 {
    font-size: 16px;
    color: var(--primary);
    margin: 0;
}

.item-badge {
    background: var(--primary);
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
}

.item-detail {
    font-size: 13px;
    color: var(--text-light);
    margin-bottom: 8px;
}

.item-detail:last-child {
    margin-bottom: 0;
}

.empty-state {
    text-align: center;
    padding: 32px;
    color: var(--text-light);
    font-style: italic;
}

/* ==================== Preview Panel ==================== */
.preview-panel {
    position: sticky;
    top: 24px;
    height: fit-content;
}

.preview-section {
    background: white;
    padding: 20px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.preview-section h2 {
    font-size: 16px;
    margin-bottom: 16px;
    color: var(--primary);
}

.scenery-preview {
    max-height: 600px;
    overflow-y: auto;
}

.preview-content h3 {
    color: var(--primary);
    margin-bottom: 12px;
    font-size: 16px;
}

.preview-content p {
    font-size: 13px;
    color: var(--text);
    margin-bottom: 10px;
    line-height: 1.5;
}

.placeholder {
    color: var(--text-light);
    font-style: italic;
    text-align: center;
    padding: 20px;
}

/* ==================== Browse Container ==================== */
.browse-container {
    background: white;
    padding: 24px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.browse-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    gap: 16px;
}

.browse-header h2 {
    color: var(--primary);
    margin: 0;
}

.search-input {
    flex: 1;
    max-width: 300px;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 14px;
}

.search-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(30, 144, 255, 0.1);
}

.scenery-list {
    display: grid;
    gap: 16px;
}

.scenery-card {
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 16px;
    transition: all 0.3s ease;
    cursor: pointer;
}

.scenery-card:hover {
    box-shadow: var(--shadow);
    border-color: var(--primary);
}

.scenery-card h3 {
    color: var(--primary);
    margin-bottom: 8px;
    font-size: 16px;
}

.scenery-card p {
    font-size: 13px;
    color: var(--text-light);
    margin-bottom: 8px;
}

/* ==================== Import Section ==================== */
.import-section {
    background: #f9f9f9;
    border: 2px dashed var(--border);
    border-radius: 4px;
    padding: 20px;
    text-align: center;
    margin-top: 24px;
}

.import-section h3 {
    margin-bottom: 16px;
    color: var(--primary);
}

#import-file {
    display: block;
    margin: 12px auto;
}

/* ==================== Modals ==================== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    max-width: 600px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid var(--border);
}

.modal-header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.modal-header h2 {
    color: var(--primary);
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-light);
}

.modal-close:hover {
    color: var(--text);
}

.modal-body {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.modal-actions {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 12px;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

@media (max-width: 768px) {
    .modal-actions {
        grid-template-columns: 1fr;
    }
}

/* ==================== Notifications ==================== */
.notification {
    position: fixed;
    bottom: 24px;
    right: 24px;
    padding: 16px 20px;
    border-radius: 4px;
    box-shadow: var(--shadow-lg);
    z-index: 2000;
    transform: translateX(400px);
    transition: transform 0.3s ease;
    max-width: 350px;
}

.notification.show {
    transform: translateX(0);
}

.notification.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.notification.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.notification.warning {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffeeba;
}

/* ==================== Scrollbar ==================== */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #999;
}

/* ==================== Responsive ==================== */
@media (max-width: 768px) {
    .scenery-header {
        flex-direction: column;
        gap: 16px;
    }
    
    .header-nav {
        width: 100%;
    }

    .section-header,
    .modal-header {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .generation-controls,
    .generation-model-picker {
        justify-content: stretch;
        width: 100%;
    }

    .generation-model-picker {
        flex-direction: column;
        align-items: stretch;
    }

    .generation-model-picker select {
        min-width: 0;
        width: 100%;
    }

    .section-actions,
    .modal-header-actions {
        width: 100%;
        justify-content: stretch;
    }
    
    .scenery-main {
        padding: 12px;
    }
    
    .scenery-editor-container {
        grid-template-columns: 1fr;
    }
    
    .preview-panel {
        position: static;
    }
}
