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

:root {
    --bg-primary: #1a2332;
    --bg-secondary: #243447;
    --bg-tertiary: #2d3e52;
    --bg-hover: #3a4d64;
    --text-primary: #ffffff;
    --text-secondary: #a8b3c1;
    --text-muted: #6b7a8f;
    --border-color: #3a4d64;
    --accent-blue: #4a90e2;
    --accent-green: #5cb85c;
    --accent-red: #d9534f;
    --shadow: rgba(0, 0, 0, 0.3);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
}

/* App Container */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 250px;
    background-color: var(--bg-secondary);
    padding: 20px 0;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border-color);
}

.logo-container {
    display: flex;
    align-items: center;
    padding: 0 20px 30px;
    gap: 10px;
    justify-content: center;
}

.logo {
    width: 120px;
    height: auto;
    border-radius: 0;
}

.logo-text {
    font-size: 24px;
    font-weight: 600;
    background: linear-gradient(135deg, #4a90e2, #00d4ff);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    display: none;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    color: var(--text-secondary);
    text-decoration: none;
    transition: all 0.3s ease;
    gap: 12px;
    border-left: 3px solid transparent;
}

.nav-item:hover {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
}

.nav-item.active {
    background-color: var(--accent-blue);
    color: var(--text-primary);
    border-left-color: #ffffff;
}

.nav-icon {
    font-size: 18px;
    width: 24px;
    text-align: center;
}

.nav-text {
    font-size: 14px;
}

/* Main Content */
.main-content {
    flex: 1;
    padding: 30px 40px;
    overflow-y: auto;
}

.page-header {
    margin-bottom: 10px;
}

.page-title {
    font-size: 28px;
    font-weight: 600;
    color: var(--text-primary);
}

.page-description {
    color: var(--text-secondary);
    margin-bottom: 25px;
    font-size: 14px;
}

.api-provider {
    margin-bottom: 30px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.api-provider label {
    color: var(--text-primary);
    font-size: 14px;
}

#api-select {
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 8px 15px;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    outline: none;
}

/* Content Grid */
.content-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
}

/* Section Styles */
.upload-section,
.results-section {
    background-color: var(--bg-secondary);
    border-radius: 12px;
    padding: 25px;
    border: 1px solid var(--border-color);
}

.section-title {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 20px;
    color: var(--text-primary);
}

/* Upload Area */
.upload-area {
    border: 2px dashed var(--border-color);
    border-radius: 8px;
    padding: 60px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background-color: var(--bg-tertiary);
    position: relative;
    min-height: 300px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.upload-area:hover {
    border-color: var(--accent-blue);
    background-color: var(--bg-hover);
}

.upload-area.dragover {
    border-color: var(--accent-blue);
    background-color: var(--bg-hover);
}

.upload-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

.upload-icon {
    font-size: 48px;
    color: var(--accent-blue);
}

.upload-text {
    font-size: 16px;
    color: var(--text-primary);
    font-weight: 500;
}

.upload-formats {
    font-size: 13px;
    color: var(--text-muted);
}

.uploaded-image,
.image-canvas {
    max-width: 100%;
    max-height: 500px;
    width: 100%;
    height: auto;
    border-radius: 8px;
    object-fit: contain;
}

.upload-button {
    margin-top: 15px;
    padding: 10px 20px;
    background-color: var(--accent-blue);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
}

.upload-button:hover {
    background-color: #3a7bc8;
}

/* Results Section */
.results-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 20px;
    gap: 15px;
}

.results-icon {
    font-size: 48px;
    color: var(--text-muted);
}

.results-text {
    font-size: 16px;
    color: var(--text-muted);
}

.results-content {
    display: flex;
    flex-direction: column;
    gap: 25px;
}

.processing-info {
    display: flex;
    gap: 30px;
    padding: 15px;
    background-color: var(--bg-tertiary);
    border-radius: 8px;
}

.info-item {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.info-label {
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.info-value {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

.detection-images {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
}

.detection-image-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.image-label {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
}

.detection-image-wrapper {
    position: relative;
    background-color: var(--bg-tertiary);
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 300px;
}

.detection-image {
    max-width: 100%;
    max-height: 500px;
    width: 100%;
    height: auto;
    display: block;
    border-radius: 8px;
    object-fit: contain;
}

.result-canvas {
    position: absolute;
    top: 0;
    left: 0;
    pointer-events: all;
    cursor: pointer;
}

/* Detection Table */
.detection-table-container {
    margin-top: 20px;
}

.table-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 5px;
    color: var(--text-primary);
}

.table-description {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 15px;
}

.detection-table {
    width: 100%;
    border-collapse: collapse;
    background-color: var(--bg-tertiary);
    border-radius: 8px;
    overflow: hidden;
}

.detection-table thead {
    background-color: var(--bg-hover);
}

.detection-table th {
    padding: 12px 15px;
    text-align: left;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.detection-table td {
    padding: 12px 15px;
    border-top: 1px solid var(--border-color);
    font-size: 14px;
    color: var(--text-primary);
}

.detection-table .no-selection {
    text-align: center;
    color: var(--text-muted);
    font-style: italic;
}

.confidence-high {
    color: var(--accent-green);
    font-weight: 600;
}

.confidence-medium {
    color: #f0ad4e;
    font-weight: 600;
}

.confidence-low {
    color: var(--accent-red);
    font-weight: 600;
}

/* Extracted Images */
.extracted-images-section {
    margin-top: 25px;
}

.section-subtitle {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 15px;
    color: var(--text-primary);
}

.extracted-images-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 15px;
}

.extracted-image-item {
    background-color: var(--bg-tertiary);
    border-radius: 8px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.extracted-image-label {
    font-size: 12px;
    color: var(--text-secondary);
    text-align: center;
}

.extracted-image {
    width: 100%;
    height: auto;
    border-radius: 6px;
}

/* Bounding Box Styles */
.bbox-overlay {
    position: absolute;
    border: 2px solid transparent;
    transition: all 0.2s ease;
    cursor: pointer;
}

.bbox-overlay:hover {
    border-width: 3px;
    box-shadow: 0 0 20px rgba(74, 144, 226, 0.6);
}

.bbox-overlay.selected {
    border-width: 3px;
    box-shadow: 0 0 25px rgba(74, 144, 226, 0.8);
}

/* Loading Spinner */
.loading-spinner {
    display: inline-block;
    width: 40px;
    height: 40px;
    border: 4px solid var(--border-color);
    border-top-color: var(--accent-blue);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Responsive Design */
@media (max-width: 1200px) {
    .content-grid {
        grid-template-columns: 1fr;
    }
    
    .detection-images {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .sidebar {
        width: 80px;
    }
    
    .logo-text,
    .nav-text {
        display: none;
    }
    
    .logo-container {
        justify-content: center;
    }
    
    .nav-item {
        justify-content: center;
    }
    
    .main-content {
        padding: 20px;
    }
}
