/* CAD Analyzer - Dark industrial theme */
:root {
    --bg-dark: #0f0f1a;
    --bg-card: #1a1a2e;
    --bg-card-hover: #1f1f35;
    --bg-input: #12122a;
    --accent: #4fc3f7;
    --accent-hover: #81d4fa;
    --accent-glow: rgba(79, 195, 247, 0.3);
    --text-primary: #e8eaf6;
    --text-secondary: #9e9eb8;
    --text-muted: #6c6c8a;
    --border: #2a2a4a;
    --success: #66bb6a;
    --error: #ef5350;
    --warning: #ffa726;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-dark);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
}

/* Header */
header {
    padding: 24px 0;
    border-bottom: 1px solid var(--border);
    background: linear-gradient(180deg, rgba(26, 26, 46, 0.8), transparent);
}

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

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: var(--text-primary);
}

.logo-icon {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--accent), #0288d1);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: 700;
}

.logo h1 {
    font-size: 20px;
    font-weight: 600;
    letter-spacing: -0.5px;
}

.logo span {
    color: var(--accent);
}

.badge {
    font-size: 11px;
    padding: 4px 10px;
    background: rgba(79, 195, 247, 0.1);
    border: 1px solid rgba(79, 195, 247, 0.2);
    border-radius: 20px;
    color: var(--accent);
}

/* Upload Page */
.hero {
    text-align: center;
    padding: 80px 0 40px;
}

.hero h2 {
    font-size: 42px;
    font-weight: 700;
    letter-spacing: -1px;
    margin-bottom: 16px;
    background: linear-gradient(135deg, var(--text-primary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero p {
    font-size: 18px;
    color: var(--text-secondary);
    max-width: 500px;
    margin: 0 auto;
}

/* Upload Zone */
.upload-section {
    max-width: 640px;
    margin: 0 auto;
    padding-bottom: 80px;
}

.drop-zone {
    border: 2px dashed var(--border);
    border-radius: 16px;
    padding: 60px 40px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: var(--bg-card);
    position: relative;
}

.drop-zone:hover,
.drop-zone.drag-over {
    border-color: var(--accent);
    background: rgba(79, 195, 247, 0.05);
    box-shadow: 0 0 30px var(--accent-glow);
}

.drop-zone-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 20px;
    background: rgba(79, 195, 247, 0.1);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.drop-zone-icon svg {
    width: 32px;
    height: 32px;
    stroke: var(--accent);
}

.drop-zone h3 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 8px;
}

.drop-zone p {
    color: var(--text-muted);
    font-size: 14px;
}

.drop-zone .browse-link {
    color: var(--accent);
    text-decoration: underline;
    cursor: pointer;
}

.file-info {
    display: none;
    align-items: center;
    gap: 12px;
    padding: 16px;
    background: rgba(79, 195, 247, 0.08);
    border: 1px solid rgba(79, 195, 247, 0.2);
    border-radius: 10px;
    margin-top: 16px;
}

.file-info.visible { display: flex; }

.file-info .file-name {
    flex: 1;
    font-weight: 500;
    font-size: 14px;
}

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

.file-info .remove-file {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 18px;
    padding: 4px;
}

/* Email field */
.email-field {
    margin-top: 20px;
}

.email-field label {
    display: block;
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 6px;
    font-weight: 500;
}

.email-field input {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text-primary);
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

.email-field input:focus {
    border-color: var(--accent);
}

.email-field input::placeholder {
    color: var(--text-muted);
}

/* Submit button */
.submit-btn {
    width: 100%;
    margin-top: 20px;
    padding: 14px;
    background: linear-gradient(135deg, #0288d1, var(--accent));
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    letter-spacing: 0.3px;
}

.submit-btn:hover {
    box-shadow: 0 4px 20px var(--accent-glow);
    transform: translateY(-1px);
}

.submit-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Loading overlay */
.loading-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 15, 26, 0.9);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 24px;
}

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

.spinner {
    width: 48px;
    height: 48px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.loading-overlay p {
    font-size: 16px;
    color: var(--text-secondary);
}

/* Error message */
.error-msg {
    padding: 14px 18px;
    background: rgba(239, 83, 80, 0.1);
    border: 1px solid rgba(239, 83, 80, 0.3);
    border-radius: 10px;
    color: var(--error);
    font-size: 14px;
    margin-bottom: 20px;
}

/* ========= Results Page ========= */
.results-header {
    padding: 40px 0 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 16px;
}

.results-header h2 {
    font-size: 28px;
    font-weight: 700;
}

.back-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text-primary);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
}

.back-btn:hover {
    border-color: var(--accent);
    background: var(--bg-card-hover);
}

/* Stats grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
    transition: all 0.2s;
}

.stat-card:hover {
    border-color: rgba(79, 195, 247, 0.3);
    transform: translateY(-2px);
}

.stat-card .label {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.stat-card .value {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
}

.stat-card .value.accent { color: var(--accent); }

.stat-card .unit {
    font-size: 14px;
    font-weight: 400;
    color: var(--text-secondary);
    margin-left: 4px;
}

/* Two-column layout */
.results-body {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    margin-bottom: 40px;
}

@media (max-width: 900px) {
    .results-body {
        grid-template-columns: 1fr;
    }
}

.panel {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
}

.panel-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.panel-body {
    padding: 20px;
}

/* Detail table */
.detail-table {
    width: 100%;
}

.detail-table tr {
    border-bottom: 1px solid rgba(42, 42, 74, 0.5);
}

.detail-table tr:last-child { border-bottom: none; }

.detail-table td {
    padding: 10px 0;
    font-size: 14px;
}

.detail-table td:first-child {
    color: var(--text-muted);
}

.detail-table td:last-child {
    text-align: right;
    font-weight: 500;
    color: var(--text-primary);
}

/* Face breakdown */
.face-bar {
    display: flex;
    height: 8px;
    border-radius: 4px;
    overflow: hidden;
    margin: 16px 0;
    background: var(--bg-dark);
}

.face-bar-segment {
    transition: width 0.6s ease;
}

.face-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    font-size: 12px;
    color: var(--text-secondary);
}

.face-legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.face-legend-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

/* 3D Viewer */
#viewer-container {
    width: 100%;
    aspect-ratio: 4 / 3;
    background: #0a0a1a;
    border-radius: 8px;
    position: relative;
    overflow: hidden;
}

#viewer-container canvas {
    width: 100% !important;
    height: 100% !important;
}

.viewer-controls {
    position: absolute;
    bottom: 12px;
    right: 12px;
    display: flex;
    gap: 6px;
    z-index: 10;
}

.viewer-controls button {
    width: 32px;
    height: 32px;
    background: rgba(26, 26, 46, 0.8);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    transition: all 0.2s;
}

.viewer-controls button:hover {
    background: var(--bg-card);
    color: var(--accent);
    border-color: var(--accent);
}

/* Email notification */
.email-notification {
    padding: 14px 18px;
    background: rgba(102, 187, 106, 0.1);
    border: 1px solid rgba(102, 187, 106, 0.3);
    border-radius: 10px;
    color: var(--success);
    font-size: 14px;
    margin-bottom: 20px;
}

/* Footer */
footer {
    padding: 24px 0;
    border-top: 1px solid var(--border);
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.animate-in {
    animation: fadeIn 0.4s ease forwards;
}

.animate-in:nth-child(2) { animation-delay: 0.05s; }
.animate-in:nth-child(3) { animation-delay: 0.1s; }
.animate-in:nth-child(4) { animation-delay: 0.15s; }
.animate-in:nth-child(5) { animation-delay: 0.2s; }
