/* ============================================================
   AI-SDLC — Modern Dark Theme
   ============================================================ */

:root {
    --bg-primary: #0f1117;
    --bg-secondary: #1a1d27;
    --bg-card: #21242f;
    --bg-hover: #2a2e3b;
    --border: #2e3244;
    --text-primary: #e4e6ed;
    --text-secondary: #8b8fa3;
    --text-muted: #5c6078;
    --accent: #6366f1;
    --accent-hover: #818cf8;
    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #3b82f6;
    --critical: #dc2626;
    --radius: 8px;
    --radius-lg: 12px;
    --shadow: 0 2px 8px rgba(0,0,0,0.3);
    --transition: 0.2s ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

a {
    color: var(--accent);
    text-decoration: none;
    transition: color var(--transition);
}
a:hover { color: var(--accent-hover); }

/* ── Layout ──────────────────────────────────────────── */

.app-container {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 240px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    padding: 20px 0;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    overflow-y: auto;
    z-index: 100;
}

.sidebar-logo {
    padding: 0 20px 20px;
    font-size: 18px;
    font-weight: 700;
    color: var(--accent);
    border-bottom: 1px solid var(--border);
    margin-bottom: 12px;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    color: var(--text-secondary);
    font-size: 14px;
    transition: all var(--transition);
    border-left: 3px solid transparent;
}
.sidebar-nav a:hover,
.sidebar-nav a.active {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-left-color: var(--accent);
}

.main-content {
    margin-left: 240px;
    flex: 1;
    padding: 24px 32px;
    min-height: 100vh;
}

/* ── Header ──────────────────────────────────────────── */

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.page-header h1 {
    font-size: 24px;
    font-weight: 600;
}

/* ── Buttons ─────────────────────────────────────────── */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: none;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    font-family: inherit;
}

.btn-primary {
    background: var(--accent);
    color: #fff;
}
.btn-primary:hover { background: var(--accent-hover); }

.btn-secondary {
    background: var(--bg-hover);
    color: var(--text-primary);
    border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--border); }

.btn-danger {
    background: var(--danger);
    color: #fff;
}
.btn-danger:hover { opacity: 0.9; }

.btn-sm {
    padding: 4px 10px;
    font-size: 12px;
}

/* ── Cards ───────────────────────────────────────────── */

.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    margin-bottom: 16px;
    transition: border-color var(--transition);
}
.card:hover { border-color: var(--accent); }

/* ── Kanban Board ────────────────────────────────────── */

.kanban-board {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    min-height: 500px;
}

.kanban-column {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 16px;
    min-height: 400px;
}

.kanban-column-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.kanban-column-header h3 {
    font-size: 14px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.kanban-column-count {
    background: var(--bg-hover);
    color: var(--text-secondary);
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 12px;
}

.kanban-cards {
    min-height: 200px;
    padding: 4px;
    border-radius: var(--radius);
    transition: background var(--transition), border-color var(--transition);
    border: 2px dashed transparent;
}
.kanban-cards.drag-over {
    background: rgba(99, 102, 241, 0.08);
    border-color: var(--accent);
}

.kanban-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px;
    margin-bottom: 8px;
    cursor: grab;
    transition: all var(--transition);
    user-select: none;
}
.kanban-card * {
    pointer-events: none;
}
.kanban-card:active {
    cursor: grabbing;
}
.kanban-card:hover {
    border-color: var(--accent);
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}
.kanban-card.dragging {
    opacity: 0.4;
    transform: rotate(2deg);
    box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}

.kanban-card-title {
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 8px;
}

.kanban-card-meta {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* ── Badges ──────────────────────────────────────────── */

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.badge-low       { background: #1e3a2f; color: #4ade80; }
.badge-medium    { background: #3b2f1e; color: #fbbf24; }
.badge-high      { background: #3b1e1e; color: #f87171; }
.badge-critical  { background: #4c0519; color: #fda4af; }
.badge-minor     { background: #1e3a2f; color: #4ade80; }
.badge-major     { background: #3b2f1e; color: #fbbf24; }
.badge-blocker   { background: #4c0519; color: #fda4af; }

.badge-backlog   { background: #1e293b; color: #94a3b8; }
.badge-active    { background: #1e3a5f; color: #60a5fa; }
.badge-review    { background: #3b2f1e; color: #fbbf24; }
.badge-done      { background: #1e3a2f; color: #4ade80; }
.badge-archived  { background: #27272a; color: #71717a; }

/* ── Forms ───────────────────────────────────────────── */

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.form-control {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    transition: border-color var(--transition);
}
.form-control:focus {
    outline: none;
    border-color: var(--accent);
}

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%238b8fa3' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px;
}

textarea.form-control {
    min-height: 100px;
    resize: vertical;
}

/* ── Modal ───────────────────────────────────────────── */

.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}
.modal-overlay.active {
    display: flex;
}

.modal {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.modal-header h2 {
    font-size: 18px;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 24px;
    cursor: pointer;
    padding: 4px;
    line-height: 1;
}
.modal-close:hover { color: var(--text-primary); }

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

/* ── Tree View ───────────────────────────────────────── */

.tree-item {
    margin-bottom: 4px;
}

.tree-toggle {
    cursor: pointer;
    user-select: none;
    padding: 8px 12px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background var(--transition);
}
.tree-toggle:hover { background: var(--bg-hover); }

.tree-toggle-icon {
    font-size: 10px;
    transition: transform var(--transition);
    color: var(--text-muted);
    width: 16px;
    text-align: center;
}
.tree-toggle-icon.open { transform: rotate(90deg); }

.tree-children {
    padding-left: 24px;
    display: none;
}
.tree-children.open { display: block; }

.tree-label {
    font-weight: 500;
    font-size: 14px;
}

.tree-label-epic { color: var(--accent); }
.tree-label-feature { color: var(--info); }
.tree-label-story { color: var(--text-primary); }

/* ── Sprint Page ─────────────────────────────────────── */

.sprint-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 16px;
    text-align: center;
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--accent);
}

.stat-label {
    font-size: 12px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 4px;
}

/* ── Markdown Editor ─────────────────────────────────── */

.md-editor {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    min-height: 400px;
}

.md-editor-input {
    width: 100%;
    min-height: 400px;
    padding: 16px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 14px;
    resize: vertical;
}
.md-editor-input:focus {
    outline: none;
    border-color: var(--accent);
}

.md-preview {
    padding: 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow-y: auto;
}

.md-preview h1, .md-preview h2, .md-preview h3 {
    margin: 16px 0 8px;
    color: var(--text-primary);
}
.md-preview p { margin-bottom: 8px; }
.md-preview code {
    background: var(--bg-primary);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 13px;
}
.md-preview pre {
    background: var(--bg-primary);
    padding: 12px;
    border-radius: var(--radius);
    overflow-x: auto;
    margin: 8px 0;
}
.md-preview ul, .md-preview ol {
    padding-left: 20px;
    margin-bottom: 8px;
}

/* ── Login Page ──────────────────────────────────────── */

.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: var(--bg-primary);
}

.login-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 40px;
    width: 100%;
    max-width: 420px;
}

.login-card h1 {
    text-align: center;
    margin-bottom: 8px;
    font-size: 24px;
}

.login-card p {
    text-align: center;
    color: var(--text-secondary);
    margin-bottom: 24px;
    font-size: 14px;
}

/* ── Table ───────────────────────────────────────────── */

.table-container {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    padding: 10px 14px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}

th {
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

tr:hover td { background: var(--bg-hover); }

/* ── Alerts ──────────────────────────────────────────── */

.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    font-size: 14px;
}
.alert-error {
    background: #3b1e1e;
    color: #f87171;
    border: 1px solid #7f1d1d;
}
.alert-success {
    background: #1e3a2f;
    color: #4ade80;
    border: 1px solid #14532d;
}

/* ── Tabs ────────────────────────────────────────────── */

.tabs {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 20px;
}

.tab {
    padding: 10px 16px;
    font-size: 14px;
    color: var(--text-secondary);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all var(--transition);
    background: none;
    border-top: none;
    border-left: none;
    border-right: none;
    font-family: inherit;
}
.tab:hover { color: var(--text-primary); }
.tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

/* ── Utility ─────────────────────────────────────────── */

.flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.gap-8 { gap: 8px; }
.gap-16 { gap: 16px; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.mt-16 { margin-top: 16px; }
.mb-16 { margin-bottom: 16px; }
.text-muted { color: var(--text-secondary); }
.text-sm { font-size: 13px; }
.hidden { display: none !important; }

/* ── Responsive ──────────────────────────────────────── */

@media (max-width: 1024px) {
    .kanban-board {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .sidebar {
        width: 60px;
        overflow: hidden;
    }
    .sidebar-logo { font-size: 0; }
    .sidebar-nav a span { display: none; }
    .main-content { margin-left: 60px; padding: 16px; }
    .kanban-board { grid-template-columns: 1fr; }
    .md-editor { grid-template-columns: 1fr; }
}
