/* ==========================================================
   DS-AUDIT ONLINE – Main Stylesheet
   Version: 1.0.0
   ========================================================== */

/* --- Reset & Base --- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --primary-color: #1a73e8;
    --secondary-color: #004a9f;
    --primary-light: #1a73e822;
    --primary-hover: #004a9f;
    --bg-dark: #0f1923;
    --bg-card: #1a2332;
    --bg-card-hover: #1e2a3a;
    --bg-body: #0b1117;
    --text-primary: #e8edf3;
    --text-secondary: #8899aa;
    --text-muted: #556677;
    --border-color: #2a3a4a;
    --border-light: #1e2e3e;
    --success: #28a745;
    --warning: #ffc107;
    --danger: #dc3545;
    --info: #17a2b8;
    --orange: #fd7e14;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 4px 24px rgba(0,0,0,0.3);
    --shadow-sm: 0 2px 12px rgba(0,0,0,0.2);
    --transition: all 0.3s ease;
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-family);
    background: var(--bg-body);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a {
    color: var(--primary-color);
    text-decoration: none;
    transition: var(--transition);
}

a:hover {
    color: var(--primary-hover);
    text-decoration: underline;
}

/* --- Navigation --- */
.main-nav {
    background: var(--bg-dark);
    border-bottom: 1px solid var(--border-color);
    padding: 0 2rem;
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    max-width: 1600px;
    margin: 0 auto;
    height: 60px;
}

.nav-brand a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
}

.nav-logo {
    height: 32px;
    width: auto;
}

.nav-title {
    font-weight: 600;
    font-size: 1.1rem;
    color: var(--text-primary);
}

.nav-links {
    display: flex;
    gap: 0.25rem;
}

.nav-link {
    padding: 0.5rem 1rem;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.9rem;
    transition: var(--transition);
    text-decoration: none;
}

.nav-link:hover, .nav-link.active {
    color: var(--text-primary);
    background: var(--primary-light);
    text-decoration: none;
}

.nav-user {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.nav-user-name {
    font-size: 0.85rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.nav-role-badge {
    background: var(--primary-light);
    color: var(--primary-color);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
}

.nav-logout {
    color: var(--text-muted) !important;
}

.nav-logout:hover {
    color: var(--danger) !important;
}

/* --- Main Content --- */
.main-content {
    flex: 1;
    max-width: 1600px;
    width: 100%;
    margin: 0 auto;
    padding: 2rem;
}

/* --- Flash Messages --- */
.flash-container {
    max-width: 1600px;
    margin: 1rem auto 0;
    padding: 0 2rem;
}

.flash {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    animation: slideDown 0.3s ease;
}

.flash-success {
    background: #28a74520;
    border: 1px solid #28a74540;
    color: #7dcea0;
}

.flash-error {
    background: #dc354520;
    border: 1px solid #dc354540;
    color: #f1948a;
}

.flash-warning {
    background: #ffc10720;
    border: 1px solid #ffc10740;
    color: #f9e79f;
}

.flash-close {
    margin-left: auto;
    background: none;
    border: none;
    color: inherit;
    font-size: 1.2rem;
    cursor: pointer;
    opacity: 0.6;
}

.flash-close:hover { opacity: 1; }

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1.25rem;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid transparent;
    transition: var(--transition);
    text-decoration: none;
    white-space: nowrap;
}

.btn:hover { text-decoration: none; }

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

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

.btn-secondary {
    background: var(--bg-card);
    color: var(--text-secondary);
    border-color: var(--border-color);
}

.btn-secondary:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
}

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

.btn-outline:hover {
    background: var(--primary-light);
    color: var(--primary-color);
}

.btn-lg {
    padding: 0.75rem 2rem;
    font-size: 1rem;
}

.btn-sm {
    padding: 0.35rem 0.75rem;
    font-size: 0.8rem;
}

/* --- Cards --- */
.score-card, .stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 1.5rem;
    transition: var(--transition);
}

.score-card:hover, .stat-card:hover {
    border-color: var(--primary-color);
    box-shadow: var(--shadow-sm);
}

/* --- Score Cards Grid --- */
.score-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.score-card-primary {
    border-color: var(--primary-color);
    border-width: 2px;
}

.score-card-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-bottom: 0.75rem;
}

.score-value {
    font-size: 2.5rem;
    font-weight: 700;
    line-height: 1.1;
    margin-bottom: 0.5rem;
}

.score-maturity {
    margin-bottom: 0.5rem;
}

.score-delta {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border-light);
    font-size: 0.85rem;
}

.delta-up { color: var(--success); font-weight: 600; }
.delta-down { color: var(--danger); font-weight: 600; }
.delta-neutral { color: var(--text-muted); }
.delta-label { color: var(--text-muted); font-size: 0.75rem; margin-left: 0.5rem; }

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

.stat-card {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: var(--primary-light);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary-color);
    font-size: 1.2rem;
    flex-shrink: 0;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    display: block;
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* --- Badges --- */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.6rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    gap: 0.25rem;
}

.badge-ism {
    background: #17a2b830;
    color: var(--info);
}

/* --- Forms --- */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.35rem;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.6rem 0.85rem;
    background: var(--bg-dark);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.9rem;
    transition: var(--transition);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.form-grid {
    display: grid;
    gap: 1rem;
}

.form-grid.two-cols { grid-template-columns: 1fr 1fr; }
.form-grid.three-cols { grid-template-columns: 1fr 1fr 1fr; }

.required-mark { color: var(--danger); }

/* --- Wizard --- */
.wizard-container {
    max-width: 960px;
    margin: 0 auto;
}

.wizard-header {
    margin-bottom: 2rem;
}

.wizard-header h1 {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.wizard-subtitle {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.wizard-section {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.section-title {
    font-size: 1.15rem;
    font-weight: 600;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.section-hint {
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-bottom: 1rem;
}

/* --- Level Cards --- */
.level-cards {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.level-card {
    position: relative;
    border: 2px solid var(--border-color);
    border-radius: var(--radius);
    padding: 1.5rem;
    cursor: pointer;
    transition: var(--transition);
}

.level-card:hover {
    border-color: var(--primary-color);
}

.level-card.selected {
    border-color: var(--primary-color);
    background: var(--primary-light);
}

.level-card input[type="radio"] {
    position: absolute;
    opacity: 0;
}

.level-icon {
    font-size: 2rem;
    margin-bottom: 0.75rem;
}

.level-card h3 {
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
}

.level-card p {
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-bottom: 0.75rem;
}

.level-features {
    list-style: none;
}

.level-features li {
    font-size: 0.8rem;
    color: var(--text-secondary);
    padding: 0.15rem 0;
}

.level-features li i {
    color: var(--success);
    margin-right: 0.25rem;
}

.badge-premium {
    background: var(--orange);
    color: #fff;
    position: absolute;
    top: 1rem;
    right: 1rem;
}

/* --- Checkbox/Module Cards --- */
.checkbox-grid, .module-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 0.75rem;
}

.checkbox-card, .module-card {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
}

.checkbox-card:hover, .module-card:hover {
    border-color: var(--primary-color);
    background: var(--primary-light);
}

.checkbox-card input:checked ~ .checkbox-label,
.module-card input:checked ~ .module-content {
    color: var(--primary-color);
}

.module-icon {
    font-size: 1.2rem;
    color: var(--primary-color);
}

.module-name {
    display: block;
    font-weight: 500;
    font-size: 0.85rem;
}

.module-desc {
    display: block;
    font-size: 0.7rem;
    color: var(--text-muted);
}

/* --- Toggle Switch --- */
.toggle-switch-container {
    display: flex;
    align-items: center;
}

.toggle-switch {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
}

.toggle-switch input { display: none; }

.toggle-slider {
    width: 48px;
    height: 26px;
    background: var(--border-color);
    border-radius: 13px;
    position: relative;
    transition: var(--transition);
    flex-shrink: 0;
}

.toggle-slider::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 20px;
    height: 20px;
    background: var(--text-muted);
    border-radius: 50%;
    transition: var(--transition);
}

.toggle-switch input:checked + .toggle-slider {
    background: var(--primary-color);
}

.toggle-switch input:checked + .toggle-slider::after {
    transform: translateX(22px);
    background: #fff;
}

.toggle-label {
    font-weight: 500;
}

/* --- Wizard Progress --- */
.wizard-progress {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 1rem 1.5rem;
    margin-bottom: 1.5rem;
}

.progress-info {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.progress-bar-outer {
    height: 8px;
    background: var(--bg-dark);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 0.5rem;
}

.progress-bar-inner {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), var(--info));
    border-radius: 4px;
    transition: width 0.5s ease;
}

.progress-module-name {
    font-weight: 600;
    font-size: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* --- Question Cards --- */
.question-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-bottom: 1rem;
    display: flex;
    gap: 1rem;
    transition: var(--transition);
}

.question-card:hover {
    border-color: var(--border-light);
}

.question-number {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--primary-light);
    color: var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
    flex-shrink: 0;
}

.question-main {
    flex: 1;
}

.question-text {
    font-weight: 500;
    font-size: 0.95rem;
    margin-bottom: 0.75rem;
    line-height: 1.5;
}

.question-weight-indicator {
    font-size: 0.5rem;
    color: var(--warning);
    margin-left: 0.5rem;
    letter-spacing: 2px;
}

/* --- Answer Options --- */
.answer-options {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.answer-option {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.5rem 0.85rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.85rem;
    transition: var(--transition);
    user-select: none;
}

.answer-option input { display: none; }

.answer-option:hover {
    border-color: var(--text-muted);
}

.answer-option.selected,
.answer-option input:checked + .answer-icon {
    font-weight: 600;
}

.answer-yes.selected, .answer-yes:has(input:checked) {
    background: #28a74520;
    border-color: var(--success);
    color: #7dcea0;
}

.answer-partial.selected, .answer-partial:has(input:checked) {
    background: #ffc10720;
    border-color: var(--warning);
    color: #f9e79f;
}

.answer-no.selected, .answer-no:has(input:checked) {
    background: #dc354520;
    border-color: var(--danger);
    color: #f1948a;
}

.answer-unclear.selected, .answer-unclear:has(input:checked) {
    background: #fd7e1420;
    border-color: var(--orange);
    color: #f5cba7;
}

.answer-na.selected, .answer-na:has(input:checked) {
    background: #6c757d20;
    border-color: var(--text-muted);
    color: var(--text-muted);
}

/* --- Help & Extras --- */
.help-toggle, .extras-toggle {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 0.8rem;
    cursor: pointer;
    padding: 0.25rem 0;
    transition: var(--transition);
}

.help-toggle:hover, .extras-toggle:hover {
    color: var(--primary-color);
}

.help-content, .extras-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.help-content.visible, .extras-content.visible {
    max-height: 500px;
    padding-top: 0.5rem;
}

.legal-ref, .evidence-hint {
    margin-top: 0.35rem;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.question-risk-flag {
    background: #dc354520;
    color: #f1948a;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    align-self: flex-start;
    white-space: nowrap;
}

.has-content-indicator {
    color: var(--primary-color);
    margin-left: 0.25rem;
}

/* --- Results Page --- */
.results-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.results-header h1 {
    font-size: 1.75rem;
    margin-bottom: 0.5rem;
}

.audit-meta, .audit-context-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.results-header-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* --- Achievements --- */
.achievements-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.achievement-badge {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    animation: bounceIn 0.5s ease;
}

.achievement-icon {
    font-size: 1.5rem;
}

.achievement-name {
    font-weight: 600;
    font-size: 0.85rem;
}

@keyframes bounceIn {
    0% { transform: scale(0.8); opacity: 0; }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); opacity: 1; }
}

/* --- Category Bars --- */
.category-bar-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0.75rem;
}

.category-bar-label {
    width: 300px;
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    flex-shrink: 0;
}

.cat-name { font-weight: 500; }
.cat-score { font-weight: 600; }

.category-bar-visual {
    flex: 1;
}

.cat-warning {
    color: var(--warning);
    font-size: 0.75rem;
    flex-shrink: 0;
}

/* --- Gaps Table --- */
.gaps-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.gaps-table th {
    text-align: left;
    padding: 0.75rem;
    background: var(--bg-dark);
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border-color);
}

.gaps-table td {
    padding: 0.75rem;
    border-bottom: 1px solid var(--border-light);
    vertical-align: top;
}

.gap-critical td { border-left: 3px solid var(--danger); }
.gap-high td { border-left: 3px solid var(--orange); }

/* --- Action Items --- */
.timeframe-block {
    margin-bottom: 2rem;
}

.timeframe-block h3 {
    font-size: 1.1rem;
    margin-bottom: 1rem;
}

.action-item {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 1rem;
    margin-bottom: 0.75rem;
}

.action-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.action-category {
    font-weight: 600;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.action-question {
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.action-recommendation {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.action-legal {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.35rem;
}

/* --- Data Table --- */
.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th {
    text-align: left;
    padding: 0.75rem;
    background: var(--bg-dark);
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid var(--border-color);
}

.data-table td {
    padding: 0.75rem;
    border-bottom: 1px solid var(--border-light);
    font-size: 0.85rem;
    vertical-align: middle;
}

.data-table tbody tr:hover {
    background: var(--bg-card-hover);
}

.score-mini {
    font-weight: 700;
}

.text-muted {
    color: var(--text-muted);
}

/* --- Pagination --- */
.pagination {
    display: flex;
    gap: 0.25rem;
    justify-content: center;
    margin-top: 1.5rem;
}

.page-link {
    padding: 0.4rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-decoration: none;
}

.page-link:hover {
    background: var(--primary-light);
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.page-link.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: #fff;
}

/* --- Empty State --- */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--text-muted);
}

.empty-state i {
    font-size: 3rem;
    margin-bottom: 1rem;
    display: block;
}

/* --- Footer --- */
.main-footer {
    background: var(--bg-dark);
    border-top: 1px solid var(--border-color);
    padding: 1rem 2rem;
    margin-top: auto;
}

.footer-container {
    max-width: 1600px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.footer-disclaimer {
    font-style: italic;
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .form-grid.two-cols,
    .form-grid.three-cols {
        grid-template-columns: 1fr;
    }

    .level-cards {
        grid-template-columns: 1fr;
    }

    .nav-container {
        flex-wrap: wrap;
        height: auto;
        padding: 0.5rem 0;
    }

    .nav-links {
        order: 3;
        width: 100%;
        justify-content: center;
    }

    .results-header {
        flex-direction: column;
    }

    .category-bar-row {
        flex-direction: column;
        gap: 0.25rem;
    }

    .category-bar-label {
        width: 100%;
    }

    .answer-options {
        flex-direction: column;
    }

    .answer-option {
        width: 100%;
    }
}

/* --- Print --- */
@media print {
    .main-nav, .main-footer, .wizard-actions, .results-header-actions,
    .flash-container, .btn { display: none !important; }
    
    body { background: #fff; color: #000; }
    .main-content { max-width: 100%; padding: 0; }
    .score-card, .stat-card, .wizard-section, .question-card {
        break-inside: avoid;
        border-color: #ddd;
    }
}
