/**
 * aHDL Studio - Modern Responsive CSS
 * Clean, engineering-focused styling for arithmetic hardware synthesis
 */

:root {
    --bg-page: #f8fafc;
    --bg-card: #ffffff;
    --bg-sidebar: #0f172a;
    --bg-sidebar-hover: #1e293b;
    --bg-sidebar-active: #2563eb;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --text-light: #f8fafc;
    --border-color: #e2e8f0;
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-light: #eff6ff;
    --success: #10b981;
    --success-bg: #ecfdf5;
    --danger: #ef4444;
    --danger-bg: #fef2f2;
    --warning: #f59e0b;
    --terminal-bg: #090d16;
    --terminal-text: #38bdf8;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.03);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: var(--bg-page);
    color: var(--text-main);
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* App Header */
.app-header {
    background: var(--bg-sidebar);
    color: var(--text-light);
    padding: 16px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid var(--primary);
    box-shadow: var(--shadow-md);
    position: sticky;
    top: 0;
    z-index: 100;
}

.app-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.app-logo {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 1.1rem;
    color: #fff;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.app-title h1 {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.app-title p {
    font-size: 0.8rem;
    color: #94a3b8;
}

.app-badges {
    display: flex;
    gap: 8px;
    align-items: center;
}

.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-primary {
    background: rgba(59, 130, 246, 0.2);
    color: #60a5fa;
    border: 1px solid rgba(59, 130, 246, 0.4);
}

.badge-python {
    background: rgba(16, 185, 129, 0.2);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.4);
}

/* App Layout */
.app-container {
    display: grid;
    grid-template-columns: 290px 1fr;
    flex: 1;
    min-height: calc(100vh - 72px);
}

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

/* Sidebar Navigation */
.app-sidebar {
    background: #0f172a;
    color: #94a3b8;
    padding: 20px 12px;
    border-right: 1px solid #1e293b;
    overflow-y: auto;
    max-height: calc(100vh - 72px);
    position: sticky;
    top: 72px;
}

.nav-category {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 700;
    color: #64748b;
    padding: 12px 12px 6px;
    margin-top: 8px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    color: #cbd5e1;
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.15s ease;
    margin-bottom: 2px;
}

.nav-item:hover {
    background: var(--bg-sidebar-hover);
    color: #fff;
}

.nav-item.active {
    background: var(--bg-sidebar-active);
    color: #fff;
    font-weight: 600;
    box-shadow: 0 2px 4px rgba(37, 99, 235, 0.3);
}

.nav-icon {
    font-size: 1rem;
    width: 20px;
    text-align: center;
}

/* Main Content Workspace */
.app-main {
    padding: 28px;
    overflow-y: auto;
}

.content-grid {
    display: grid;
    grid-template-columns: minmax(360px, 440px) 1fr;
    gap: 24px;
    align-items: start;
}

@media (max-width: 1200px) {
    .content-grid {
        grid-template-columns: 1fr;
    }
}

/* Cards */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    margin-bottom: 24px;
}

.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    background: #fdfdfd;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-header h2 {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-main);
}

.card-desc {
    padding: 0 20px 16px;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.card-body {
    padding: 20px;
}

/* Form Controls */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 6px;
    color: #334155;
}

.form-help {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 4px;
}

.form-control {
    width: 100%;
    padding: 9px 12px;
    font-size: 0.9rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: #fff;
    color: var(--text-main);
    transition: border-color 0.15s, box-shadow 0.15s;
    font-family: inherit;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

textarea.form-control {
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, Courier, monospace;
    font-size: 0.85rem;
    line-height: 1.4;
    resize: vertical;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.875rem;
    cursor: pointer;
    user-select: none;
}

.checkbox-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    font-size: 0.9rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.15s ease;
}

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

.btn-primary:hover {
    background: var(--primary-hover);
    box-shadow: 0 2px 4px rgba(37, 99, 235, 0.25);
}

.btn-success {
    background: var(--success);
    color: #fff;
}

.btn-success:hover {
    background: #059669;
}

.btn-outline {
    background: transparent;
    border-color: var(--border-color);
    color: #334155;
}

.btn-outline:hover {
    background: #f1f5f9;
    border-color: #cbd5e1;
}

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

.btn-block {
    width: 100%;
}

/* Metrics Grid */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.metric-box {
    background: #f8fafc;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    text-align: center;
}

.metric-val {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--primary);
    line-height: 1.1;
}

.metric-lbl {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 4px;
}

/* Alert Boxes */
.alert {
    padding: 14px 18px;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    margin-bottom: 20px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.alert-success {
    background: var(--success-bg);
    border: 1px solid #a7f3d0;
    color: #065f46;
}

.alert-danger {
    background: var(--danger-bg);
    border: 1px solid #fecaca;
    color: #991b1b;
}

/* Code & File Viewer */
.tabs-header {
    display: flex;
    background: #1e293b;
    border-bottom: 1px solid #334155;
    overflow-x: auto;
}

.tab-btn {
    background: transparent;
    color: #94a3b8;
    border: none;
    padding: 10px 16px;
    font-size: 0.825rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    border-bottom: 2px solid transparent;
    transition: all 0.15s ease;
}

.tab-btn:hover {
    color: #f8fafc;
    background: rgba(255, 255, 255, 0.05);
}

.tab-btn.active {
    color: #38bdf8;
    border-bottom-color: #38bdf8;
    background: rgba(56, 189, 248, 0.1);
}

.tab-content {
    display: none;
    position: relative;
}

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

.code-viewer-container {
    position: relative;
    background: #090d16;
}

.copy-btn {
    position: absolute;
    top: 10px;
    right: 12px;
    background: #334155;
    color: #e2e8f0;
    border: none;
    padding: 5px 10px;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    cursor: pointer;
    z-index: 10;
    opacity: 0.85;
    transition: opacity 0.15s;
}

.copy-btn:hover {
    opacity: 1;
    background: #475569;
}

pre.code-block {
    background: #090d16;
    color: #e2e8f0;
    padding: 16px;
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, Courier, monospace;
    font-size: 0.825rem;
    line-height: 1.5;
    overflow-x: auto;
    max-height: 520px;
    border-radius: 0 0 var(--radius-md) var(--radius-md);
}

/* SVG Schematic Viewer */
.schematic-box {
    background: #ffffff;
    padding: 20px;
    text-align: center;
    overflow: auto;
    max-height: 540px;
    border-radius: 0 0 var(--radius-md) var(--radius-md);
}

.schematic-box svg {
    max-width: 100%;
    height: auto;
}

/* Terminal Log */
pre.terminal-log {
    background: #090d16;
    color: #38bdf8;
    padding: 16px;
    font-family: "SFMono-Regular", Consolas, monospace;
    font-size: 0.8rem;
    max-height: 380px;
    overflow-y: auto;
    border-radius: var(--radius-sm);
}

/* File Actions Bar */
.file-actions-bar {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    padding: 14px 20px;
    background: #f8fafc;
    border-bottom: 1px solid var(--border-color);
}

/* Footer */
.app-footer {
    background: #0f172a;
    color: #64748b;
    padding: 16px 24px;
    font-size: 0.8rem;
    text-align: center;
    border-top: 1px solid #1e293b;
    margin-top: auto;
}

.app-footer a {
    color: #94a3b8;
    text-decoration: none;
}

.app-footer a:hover {
    color: #38bdf8;
}

/* Legacy Overrides */
.title {
    margin-bottom: 20px;
}
.title h2 {
    font-size: 1.4rem;
    margin-bottom: 12px;
}
