/* ============================================
   CDD Platform Dashboard v3 - Styles
   Theme: Dark Only (matches landing page)
   ============================================ */

/* CSS Variables - Color Palette from Landing */
:root {
    --bg-deep: #020617;
    --bg-card: #0f172a;
    --bg-card-hover: #1e293b;
    --bg-input: #0f172a;
    --accent-primary: #3b82f6;
    --accent-primary-hover: #2563eb;
    --accent-secondary: #8b5cf6;
    --accent-success: #22c55e;
    --accent-warning: #f59e0b;
    --accent-error: #ef4444;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --border-color: rgba(255, 255, 255, 0.1);
    --border-color-hover: rgba(59, 130, 246, 0.3);
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
    --radius: 0.75rem;
    --radius-sm: 0.5rem;
    --sidebar-width: 260px;
    --header-height: 60px;
}

/* Reset & Base */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--bg-deep);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
}

/* Skip Link */
.skip-link {
    position: absolute;
    top: -100px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--accent-primary);
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius);
    z-index: 10000;
    font-weight: 600;
    text-decoration: none;
}

.skip-link:focus {
    top: 1rem;
}

/* ============================================
   AUTH SCREEN
   ============================================ */
.auth-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: radial-gradient(circle at 50% 0%, rgba(59, 130, 246, 0.1) 0%, transparent 50%);
}

.auth-card {
    width: 100%;
    max-width: 420px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 2rem;
    box-shadow: var(--shadow-lg);
}

.auth-header {
    text-align: center;
    margin-bottom: 2rem;
}

.auth-logo {
    width: 64px;
    height: 64px;
    background: linear-gradient(135deg, var(--accent-primary) 0%, var(--accent-secondary) 100%);
    border-radius: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1rem;
}

.auth-logo i {
    width: 32px;
    height: 32px;
    color: white;
}

.auth-header h1 {
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--text-primary);
}

.auth-header h1 span {
    color: var(--accent-primary);
}

.auth-header p {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-top: 0.25rem;
}

.auth-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    background: var(--bg-deep);
    padding: 0.25rem;
    border-radius: var(--radius-sm);
}

.auth-tab {
    flex: 1;
    padding: 0.75rem;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.875rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s ease;
}

.auth-tab.active {
    background: var(--accent-primary);
    color: white;
}

.auth-tab:hover:not(.active) {
    color: var(--text-primary);
}

.auth-form.hidden {
    display: none;
}

.auth-error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #fca5a5;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

.auth-error.hidden {
    display: none;
}

/* ============================================
   FORM ELEMENTS
   ============================================ */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.9375rem;
    font-family: inherit;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.form-group input::placeholder {
    color: var(--text-muted);
}

.form-hint {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

/* ============================================
   BUTTONS
   ============================================ */
.btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    background: linear-gradient(135deg, var(--accent-primary) 0%, var(--accent-primary-hover) 100%);
    color: white;
    font-weight: 600;
    font-size: 0.9375rem;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    box-shadow: 0 4px 14px rgba(37, 99, 235, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(37, 99, 235, 0.4);
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.btn-full {
    width: 100%;
}

.btn-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1rem;
    background: var(--bg-card);
    color: var(--text-primary);
    font-weight: 500;
    font-size: 0.875rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-secondary:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-color-hover);
}

.btn-danger {
    background: rgba(239, 68, 68, 0.1);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.btn-danger:hover {
    background: rgba(239, 68, 68, 0.2);
}

/* ============================================
   APP LAYOUT
   ============================================ */
.app {
    display: flex;
    min-height: 100vh;
}

.app.hidden {
    display: none;
}

/* Sidebar */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--bg-card);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    z-index: 100;
}

.sidebar-header {
    padding: 1.25rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.sidebar-logo i {
    width: 32px;
    height: 32px;
    padding: 6px;
    background: var(--accent-primary);
    border-radius: 0.5rem;
    color: white;
}

.sidebar-logo span {
    font-size: 1.25rem;
    font-weight: 700;
}

.sidebar-logo .accent {
    color: var(--accent-primary);
}

.sidebar-close {
    display: none;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.25rem;
}

.sidebar-nav {
    flex: 1;
    padding: 1rem 0.75rem;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: var(--radius-sm);
    font-weight: 500;
    font-size: 0.9375rem;
    transition: all 0.2s ease;
    margin-bottom: 0.25rem;
}

.nav-item i {
    width: 20px;
    height: 20px;
}

.nav-item:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
}

.nav-item.active {
    background: rgba(59, 130, 246, 0.15);
    color: var(--accent-primary);
}

.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid var(--border-color);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.user-avatar {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1rem;
    color: white;
}

.user-info {
    flex: 1;
    min-width: 0;
}

.user-name {
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-email {
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.btn-logout {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem;
    background: rgba(239, 68, 68, 0.1);
    color: #f87171;
    border: none;
    border-radius: var(--radius-sm);
    font-weight: 500;
    font-size: 0.875rem;
    cursor: pointer;
    transition: background 0.2s ease;
}

.btn-logout i {
    width: 18px;
    height: 18px;
}

.btn-logout:hover {
    background: rgba(239, 68, 68, 0.2);
}

/* Mobile Header */
.mobile-header {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    padding: 0 1rem;
    align-items: center;
    gap: 1rem;
    z-index: 90;
}

.menu-toggle {
    background: none;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    padding: 0.5rem;
}

.menu-toggle i {
    width: 24px;
    height: 24px;
}

.mobile-logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 700;
    font-size: 1.125rem;
}

.mobile-logo i {
    width: 24px;
    height: 24px;
    color: var(--accent-primary);
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 2rem;
    min-height: 100vh;
}

/* Sidebar Overlay (Mobile) */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99;
}

.sidebar-overlay.active {
    display: block;
}

/* ============================================
   TOAST NOTIFICATIONS
   ============================================ */
#toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toast {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1.25rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    min-width: 280px;
    max-width: 420px;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(100%);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.toast.success {
    border-left: 3px solid var(--accent-success);
}

.toast.error {
    border-left: 3px solid var(--accent-error);
}

.toast.warning {
    border-left: 3px solid var(--accent-warning);
}

.toast.info {
    border-left: 3px solid var(--accent-primary);
}

.toast-icon {
    flex-shrink: 0;
}

.toast-icon i {
    width: 20px;
    height: 20px;
}

.toast.success .toast-icon {
    color: var(--accent-success);
}

.toast.error .toast-icon {
    color: var(--accent-error);
}

.toast.warning .toast-icon {
    color: var(--accent-warning);
}

.toast.info .toast-icon {
    color: var(--accent-primary);
}

.toast-message {
    flex: 1;
    font-size: 0.875rem;
    color: var(--text-primary);
}

/* ============================================
   CARDS & PANELS
   ============================================ */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    overflow: hidden;
}

.card-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-title {
    font-size: 1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.card-title i {
    width: 20px;
    height: 20px;
    color: var(--accent-primary);
}

.card-body {
    padding: 1.25rem;
}

/* Stats Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 1.25rem;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--accent-primary);
}

.stat-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

/* ============================================
   TABLES
   ============================================ */
.table-container {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    padding: 0.875rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.data-table th {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.data-table td {
    font-size: 0.875rem;
    color: var(--text-primary);
}

.data-table tbody tr {
    cursor: pointer;
    transition: background 0.2s ease;
}

.data-table tbody tr:hover {
    background: var(--bg-card-hover);
}

/* ============================================
   BADGES
   ============================================ */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.625rem;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 9999px;
    text-transform: capitalize;
}

.badge-draft {
    background: rgba(148, 163, 184, 0.15);
    color: #94a3b8;
}

.badge-review {
    background: rgba(245, 158, 11, 0.15);
    color: #fbbf24;
}

.badge-approved {
    background: rgba(34, 197, 94, 0.15);
    color: #4ade80;
}

.badge-deprecated {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
}

/* ============================================
   VIEWS
   ============================================ */
.view {
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.view-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
}

.view-title {
    font-size: 1.5rem;
    font-weight: 700;
}

.breadcrumbs {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.breadcrumbs a {
    color: var(--accent-primary);
    text-decoration: none;
}

.breadcrumbs a:hover {
    text-decoration: underline;
}

/* ============================================
   PROSE (Rendered Markdown)
   ============================================ */
.prose {
    color: var(--text-primary);
    line-height: 1.75;
}

.prose h1,
.prose h2,
.prose h3,
.prose h4 {
    color: var(--text-primary);
    font-weight: 700;
    margin-top: 1.5em;
    margin-bottom: 0.5em;
}

.prose h1 {
    font-size: 2rem;
}

.prose h2 {
    font-size: 1.5rem;
}

.prose h3 {
    font-size: 1.25rem;
}

.prose h4 {
    font-size: 1.125rem;
}

.prose p {
    margin-bottom: 1em;
}

.prose ul,
.prose ol {
    margin-bottom: 1em;
    padding-left: 1.5em;
}

.prose li {
    margin-bottom: 0.25em;
}

.prose code {
    background: var(--bg-deep);
    padding: 0.125rem 0.375rem;
    border-radius: 0.25rem;
    font-size: 0.875em;
    font-family: 'SF Mono', Monaco, monospace;
}

.prose pre {
    background: var(--bg-deep);
    padding: 1rem;
    border-radius: var(--radius-sm);
    overflow-x: auto;
    margin-bottom: 1em;
}

.prose pre code {
    background: none;
    padding: 0;
}

.prose table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1em;
}

.prose th,
.prose td {
    padding: 0.625rem 1rem;
    border: 1px solid var(--border-color);
    text-align: left;
}

.prose th {
    background: var(--bg-deep);
    font-weight: 600;
}

.prose blockquote {
    border-left: 3px solid var(--accent-primary);
    padding-left: 1rem;
    margin-left: 0;
    color: var(--text-secondary);
    font-style: italic;
}

/* ============================================
   UTILITIES
   ============================================ */
.hidden {
    display: none !important;
}

.text-muted {
    color: var(--text-muted);
}

.text-center {
    text-align: center;
}

.mb-1 {
    margin-bottom: 0.25rem;
}

.mb-2 {
    margin-bottom: 0.5rem;
}

.mb-4 {
    margin-bottom: 1rem;
}

.mb-6 {
    margin-bottom: 1.5rem;
}

.gap-2 {
    gap: 0.5rem;
}

.gap-4 {
    gap: 1rem;
}

.flex {
    display: flex;
}

.items-center {
    align-items: center;
}

.justify-between {
    justify-content: space-between;
}

.grid {
    display: grid;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
}

.empty-state i {
    width: 48px;
    height: 48px;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-state p {
    font-size: 0.9375rem;
}

/* Loading Spinner */
.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-color);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-close {
        display: block;
    }

    .sidebar-overlay.active {
        display: block;
    }

    .mobile-header {
        display: flex;
    }

    .main-content {
        margin-left: 0;
        padding-top: calc(var(--header-height) + 1.5rem);
        padding-left: 1rem;
        padding-right: 1rem;
    }
}

@media (max-width: 640px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .view-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
}