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

body {
    font-family: "Microsoft YaHei UI", "Segoe UI", sans-serif;
    background-color: #F5F7FA;
    color: #2C3E50;
    font-size: 14px;
    height: 100vh;
    overflow: hidden;
}

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

.app-header {
    background-color: #FFFFFF;
    border-bottom: 1px solid #E0E0E0;
    padding: 10px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 50px;
}

.app-header h1 {
    font-size: 18px;
    color: #2196F3;
    margin: 0;
}

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

.admin-link {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 6px 12px;
    background-color: #f5f5f5;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.admin-link:hover {
    background-color: #e3f2fd;
    color: #1976D2 !important;
    transform: translateY(-1px);
}

.language-select {
    padding: 4px 8px;
    border: 1px solid #CFD8DC;
    border-radius: 4px;
    font-size: 13px;
    background-color: #FFFFFF;
    cursor: pointer;
}

.main-content {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Left Panel */
.left-panel {
    width: 320px;
    min-width: 300px;
    background-color: #F5F7FA;
    border-right: 1px solid #E0E0E0;
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    overflow-y: auto;
}

.panel-section {
    background-color: #FFFFFF;
    border: 1px solid #E0E0E0;
    border-radius: 6px;
    padding: 12px;
}

.panel-section h3 {
    font-size: 14px;
    color: #2196F3;
    margin-bottom: 10px;
    font-weight: 600;
}

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

.section-header h3 {
    margin-bottom: 0;
}

/* Right Panel */
.right-panel {
    flex: 1;
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    overflow: hidden;
    background-color: #F5F7FA;
}

/* Settings Area */
.settings-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: #FFFFFF;
    border: 1px solid #E0E0E0;
    border-radius: 8px;
    overflow: hidden;
}

.tabs {
    display: flex;
    background-color: #ECEFF1;
    border-bottom: 1px solid #E0E0E0;
}

.tab-btn {
    padding: 10px 20px;
    border: none;
    background: none;
    cursor: pointer;
    font-weight: 500;
    color: #546E7A;
    border-right: 1px solid #E0E0E0;
}

.tab-btn:hover {
    background-color: #CFD8DC;
}

.tab-btn.active {
    background-color: #FFFFFF;
    color: #2196F3;
    border-bottom: 2px solid #2196F3;
    margin-bottom: -1px;
}

.tab-content-area {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
}

.tab-pane {
    display: none;
}

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

.settings-split {
    display: flex;
    gap: 20px;
}

.settings-column {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

/* Forms & Inputs */
.form-group {
    margin-bottom: 10px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    color: #546E7A;
    font-weight: 500;
}

input[type="text"],
input[type="number"],
select {
    width: 100%;
    padding: 6px 10px;
    border: 1px solid #CFD8DC;
    border-radius: 4px;
    font-size: 13px;
    background-color: #FFFFFF;
}

input:focus,
select:focus {
    border-color: #2196F3;
    outline: none;
}

/* Buttons */
button {
    cursor: pointer;
    font-family: inherit;
    transition: background-color 0.2s;
}

.primary-btn {
    background-color: #2196F3;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 8px 16px;
    font-weight: 500;
}

.primary-btn:hover {
    background-color: #1976D2;
}

.primary-btn:disabled {
    background-color: #BDBDBD;
    cursor: not-allowed;
}

.secondary-btn {
    background-color: #ECEFF1;
    color: #546E7A;
    border: none;
    border-radius: 4px;
    padding: 6px 12px;
    font-size: 12px;
}

.secondary-btn:hover {
    background-color: #CFD8DC;
}

.large-btn {
    width: 100%;
    padding: 12px;
    font-size: 16px;
}

.icon-btn {
    background: none;
    border: none;
    font-size: 16px;
    padding: 4px;
}

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

/* File List */
.file-list-container {
    height: 200px;
    border: 1px solid #E0E0E0;
    border-radius: 4px;
    overflow-y: auto;
    background-color: #FFFFFF;
}

.file-list {
    list-style: none;
}

.file-list li {
    padding: 8px 10px;
    border-bottom: 1px solid #F5F5F5;
    font-size: 13px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.file-list li:hover {
    background-color: #F5F7FA;
}

.file-list li .remove-btn {
    color: #EF5350;
    cursor: pointer;
    margin-left: 10px;
}

/* Log Box */
.log-container {
    height: 200px;
    background-color: #FFFFFF;
    border: 1px solid #E0E0E0;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
}

.log-header {
    padding: 8px 15px;
    border-bottom: 1px solid #E0E0E0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.log-header h3 {
    font-size: 14px;
    color: #546E7A;
    margin: 0;
}

.log-box {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
    font-family: Consolas, Monaco, monospace;
    font-size: 12px;
    color: #333;
    white-space: pre-wrap;
}

.log-entry {
    margin-bottom: 2px;
}

.log-entry.error {
    color: #D32F2F;
}

.log-entry.info {
    color: #1976D2;
}

/* Utilities */
.hint {
    display: block;
    margin-top: 5px;
    color: #90A4AE;
    font-size: 12px;
}

.full-width-select {
    width: 100%;
}

/* Checkbox wrapper */
.checkbox-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
}

.checkbox-wrapper input[type="checkbox"] {
    width: auto;
}

.checkbox-wrapper label {
    margin-bottom: 0;
}

/* API Keys / Env Editor */
.env-editor-container {
    padding: 20px;
}

.env-hint {
    color: #90A4AE;
    font-size: 14px;
    margin-bottom: 20px;
    padding: 10px;
    background: #F5F5F5;
    border-radius: 4px;
}

#env-inputs-container {
    display: flex;
    flex-direction: column;
    gap: 15px;
    max-width: 600px;
}

#env-inputs-container .form-group {
    margin-bottom: 0;
}

/* Upload Sections */
.upload-section {
    margin-top: 20px;
    padding: 15px;
    background: #F5F5F5;
    border-radius: 4px;
}

.upload-section h4 {
    margin-top: 0;
    margin-bottom: 10px;
    color: #333;
}

.upload-area {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.upload-hint {
    margin: 0;
    font-size: 12px;
    color: #666;
}

/* Results Section */
.results-section {
    max-height: 400px;
    display: flex;
    flex-direction: column;
}

.results-list-container {
    flex: 1;
    overflow-y: auto;
    min-height: 100px;
    max-height: 300px;
}

.results-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.results-list li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 10px;
    border-bottom: 1px solid #E0E0E0;
    gap: 10px;
}

.results-list li:hover {
    background: #F5F5F5;
}

.result-info {
    flex: 1;
    min-width: 0;
    cursor: pointer;
}

.result-name {
    font-size: 13px;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.result-time {
    font-size: 11px;
    color: #999;
}

.result-actions {
    display: flex;
    gap: 5px;
}

.result-btn {
    padding: 4px 8px;
    font-size: 12px;
    border: none;
    border-radius: 3px;
    cursor: pointer;
    background: #2196F3;
    color: white;
}

.result-btn:hover {
    background: #1976D2;
}

.empty-hint {
    text-align: center;
    color: #999;
    padding: 20px;
    font-size: 13px;
}

/* Results Section */
.results-section {
    margin-top: 15px;
}

.results-list-container {
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid #E0E0E0;
    border-radius: 4px;
    background-color: #FAFAFA;
}

.results-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.result-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    border-bottom: 1px solid #E0E0E0;
    background-color: #FFFFFF;
    transition: background-color 0.2s;
}

.result-item:hover {
    background-color: #F5F5F5;
}

.result-item:last-child {
    border-bottom: none;
}

.result-info {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 0;
}

.result-icon {
    font-size: 18px;
    flex-shrink: 0;
}

.result-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 13px;
    color: #2C3E50;
}

.result-time {
    font-size: 11px;
    color: #999;
    flex-shrink: 0;
    margin-left: 8px;
}

.result-actions {
    display: flex;
    gap: 5px;
    flex-shrink: 0;
}

.result-btn {
    padding: 4px 10px;
    font-size: 12px;
    border: 1px solid #CFD8DC;
    border-radius: 3px;
    background-color: #FFFFFF;
    color: #2196F3;
    cursor: pointer;
    transition: all 0.2s;
}

.result-btn:hover {
    background-color: #2196F3;
    color: #FFFFFF;
    border-color: #2196F3;
}

.result-btn.delete-btn {
    color: #F44336;
    border-color: #F44336;
    padding: 4px 8px;
    font-size: 16px;
    line-height: 1;
}

.result-btn.delete-btn:hover {
    background-color: #F44336;
    color: #FFFFFF;
}

.empty-hint {
    padding: 20px;
    text-align: center;
    color: #999;
    font-size: 13px;
}

/* Scrollbar styling for results list */
.results-list-container::-webkit-scrollbar {
    width: 8px;
}

.results-list-container::-webkit-scrollbar-track {
    background: #F5F5F5;
}

.results-list-container::-webkit-scrollbar-thumb {
    background: #CFD8DC;
    border-radius: 4px;
}

.results-list-container::-webkit-scrollbar-thumb:hover {
    background: #B0BEC5;
}

/* Image Viewer Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: white;
    border-radius: 8px;
    max-width: 95%;
    max-height: 95%;
    display: flex;
    flex-direction: column;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.image-viewer-content {
    width: 90vw;
    height: 90vh;
}

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

.modal-header h2 {
    margin: 0;
    font-size: 18px;
    color: #2196F3;
}

.close-btn {
    background: none;
    border: none;
    font-size: 32px;
    color: #999;
    cursor: pointer;
    line-height: 1;
    padding: 0;
    width: 32px;
    height: 32px;
}

.close-btn:hover {
    color: #F44336;
}

.image-viewer-body {
    display: flex;
    flex: 1;
    overflow: hidden;
}

.thumbnails-panel {
    width: 250px;
    border-right: 1px solid #E0E0E0;
    overflow-y: auto;
    background: #F5F5F5;
}

#thumbnails-container {
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.thumbnail-item {
    position: relative;
    cursor: pointer;
    border: 2px solid transparent;
    border-radius: 4px;
    overflow: hidden;
    background: white;
    transition: all 0.2s;
}

.thumbnail-item:hover {
    border-color: #2196F3;
    box-shadow: 0 2px 8px rgba(33, 150, 243, 0.3);
}

.thumbnail-item.active {
    border-color: #2196F3;
    box-shadow: 0 2px 8px rgba(33, 150, 243, 0.5);
}

.thumbnail-item img {
    width: 100%;
    height: 150px;
    object-fit: cover;
    display: block;
}

.thumbnail-item .thumbnail-name {
    padding: 8px;
    font-size: 12px;
    color: #333;
    background: white;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.thumbnail-item .thumbnail-icon {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(255, 255, 255, 0.9);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 16px;
}

.preview-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#preview-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: auto;
    background: #2C3E50;
    position: relative;
}

#preview-container img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.preview-placeholder {
    color: #999;
    font-size: 16px;
    text-align: center;
}

.preview-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    border-top: 1px solid #E0E0E0;
    background: white;
}

#preview-filename {
    font-size: 14px;
    color: #333;
    font-weight: 500;
}

.preview-actions {
    display: flex;
    gap: 10px;
}

/* Scrollbar for thumbnails */
.thumbnails-panel::-webkit-scrollbar {
    width: 8px;
}

.thumbnails-panel::-webkit-scrollbar-track {
    background: #F5F5F5;
}

.thumbnails-panel::-webkit-scrollbar-thumb {
    background: #CFD8DC;
    border-radius: 4px;
}

.thumbnails-panel::-webkit-scrollbar-thumb:hover {
    background: #B0BEC5;
}

/* Preview container scrollbar */
#preview-container::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

#preview-container::-webkit-scrollbar-track {
    background: #1a252f;
}

#preview-container::-webkit-scrollbar-thumb {
    background: #455A64;
    border-radius: 5px;
}

#preview-container::-webkit-scrollbar-thumb:hover {
    background: #546E7A;
}
