/* ============================================================================
   Lung CT Diagnosis - Modern UI Stylesheet
   ============================================================================ */

/* CSS Variables for theming - Medical/Healthcare color scheme */
:root {
    --primary-color: #0891b2;
    --primary-dark: #0e7490;
    --secondary-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --success-color: #10b981;
    --bg-color: #f0f9ff;
    --card-bg: #ffffff;
    --text-primary: #0f172a;
    --text-secondary: #64748b;
    --border-color: #e0f2fe;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --radius: 8px;
    --transition: all 0.3s ease;
}

/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

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

/* ============================================================================
   Navigation Bar
   ============================================================================ */

.navbar {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: white;
    box-shadow: var(--shadow-lg);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.nav-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 64px;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.5rem;
    font-weight: 700;
}

.nav-brand i {
    font-size: 1.75rem;
}

.nav-menu {
    display: flex;
    list-style: none;
    gap: 0.25rem;
}

.nav-menu a {
    color: white;
    text-decoration: none;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: var(--transition);
    font-weight: 500;
    font-size: 0.9rem;
}

.nav-menu a:hover {
    background: rgba(255, 255, 255, 0.1);
}

.nav-menu a.active {
    background: rgba(255, 255, 255, 0.2);
}

.nav-session {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(255, 255, 255, 0.1);
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    font-family: 'Courier New', monospace;
    font-size: 0.85rem;
}

/* ============================================================================
   Main Content Area
   ============================================================================ */

.main-content {
    flex: 1;
    max-width: 1400px;
    width: 100%;
    margin: 2rem auto;
    padding: 0 2rem;
}

/* ============================================================================
   Cards and Containers
   ============================================================================ */

.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 2rem;
    box-shadow: var(--shadow);
    margin-bottom: 2rem;
    border: 1px solid var(--border-color);
}

.card-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--border-color);
}

.card-header i {
    font-size: 2rem;
    color: var(--primary-color);
}

.card-header h2 {
    font-size: 1.75rem;
    font-weight: 700;
}

.card-body {
    margin-top: 1.5rem;
}

/* ============================================================================
   Forms
   ============================================================================ */

.form-group {
    margin-bottom: 1.5rem;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--text-primary);
}

.form-label.required::after {
    content: " *";
    color: var(--danger-color);
}

.form-input,
.form-textarea,
.form-select {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius);
    font-size: 1rem;
    font-family: inherit;
    transition: var(--transition);
    background: var(--card-bg);
}

.form-input:focus,
.form-textarea:focus,
.form-select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(8, 145, 178, 0.1);
}

.form-textarea {
    min-height: 120px;
    resize: vertical;
}

.form-help {
    display: block;
    margin-top: 0.25rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
}

/* ============================================================================
   Buttons
   ============================================================================ */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    font-family: inherit;
}

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

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn-secondary {
    background: var(--text-secondary);
    color: white;
}

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

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

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

.btn-danger {
    background: var(--danger-color);
    color: white;
}

.btn-danger:hover {
    background: #dc2626;
}

.btn-warning {
    background: var(--warning-color);
    color: white;
}

.btn-warning:hover {
    background: #d97706;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

.btn-block {
    width: 100%;
    justify-content: center;
}

.btn-group {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
    flex-wrap: wrap;
}

/* ============================================================================
   Results Display
   ============================================================================ */

.results-container {
    margin-top: 2rem;
}

.result-item {
    background: var(--bg-color);
    border: 2px solid var(--border-color);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1rem;
    transition: var(--transition);
}

.result-item:hover {
    border-color: var(--primary-color);
    box-shadow: var(--shadow);
}

.result-header {
    display: flex;
    justify-content: space-between;
    align-items: start;
    margin-bottom: 1rem;
}

.result-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.result-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.result-meta-item {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

/* ============================================================================
   Badges and Tags
   ============================================================================ */

.badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 999px;
    font-size: 0.875rem;
    font-weight: 600;
}

.badge-primary {
    background: #e0f2fe;
    color: #0369a1;
}

.badge-success {
    background: #dcfce7;
    color: #166534;
}

.badge-warning {
    background: #fef3c7;
    color: #92400e;
}

.badge-danger {
    background: #fee2e2;
    color: #991b1b;
}

.tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

/* ============================================================================
   Stats and Metrics
   ============================================================================ */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin: 1.5rem 0;
}

.stat-card {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
    padding: 1.5rem;
    border-radius: var(--radius);
    text-align: center;
    transition: var(--transition);
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.stat-value {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.stat-label {
    font-size: 0.9rem;
    opacity: 0.9;
}

/* ============================================================================
   Alerts and Messages
   ============================================================================ */

.alert {
    padding: 1rem 1.5rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.alert i {
    font-size: 1.5rem;
}

.alert-info {
    background: #e0f2fe;
    color: #0369a1;
    border: 1px solid #bae6fd;
}

.alert-success {
    background: #dcfce7;
    color: #166534;
    border: 1px solid #bbf7d0;
}

.alert-warning {
    background: #fef3c7;
    color: #92400e;
    border: 1px solid #fde68a;
}

.alert-danger {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

/* ============================================================================
   Loading States
   ============================================================================ */

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.loading-spinner {
    background: white;
    padding: 2rem 3rem;
    border-radius: var(--radius);
    text-align: center;
}

.loading-spinner i {
    font-size: 3rem;
    color: var(--primary-color);
    margin-bottom: 1rem;
}

/* ============================================================================
   Toast Notifications
   ============================================================================ */

.toast-container {
    position: fixed;
    top: 5rem;
    right: 2rem;
    z-index: 9998;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toast {
    background: white;
    padding: 1rem 1.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    min-width: 300px;
    display: flex;
    align-items: center;
    gap: 1rem;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.toast-success {
    border-left: 4px solid var(--success-color);
}

.toast-error {
    border-left: 4px solid var(--danger-color);
}

.toast-info {
    border-left: 4px solid var(--primary-color);
}

.toast-warning {
    border-left: 4px solid var(--warning-color);
}

/* ============================================================================
   Footer
   ============================================================================ */

.footer {
    background: var(--text-primary);
    color: white;
    padding: 2rem;
    text-align: center;
    margin-top: auto;
}

.footer-content {
    max-width: 1400px;
    margin: 0 auto;
}

.footer-note {
    margin-top: 0.5rem;
    font-size: 0.875rem;
    opacity: 0.7;
}

/* ============================================================================
   Responsive Design
   ============================================================================ */

@media (max-width: 1024px) {
    .nav-menu a span {
        display: none;
    }

    .nav-menu a {
        padding: 0.5rem;
    }

    .nav-session {
        display: none;
    }
}

@media (max-width: 768px) {
    .nav-container {
        flex-direction: column;
        height: auto;
        padding: 1rem;
        gap: 1rem;
    }

    .nav-menu {
        flex-wrap: wrap;
        justify-content: center;
    }

    .main-content {
        padding: 0 1rem;
    }

    .card {
        padding: 1rem;
    }

    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .toast-container {
        right: 1rem;
        left: 1rem;
    }

    .toast {
        min-width: auto;
    }

    .btn-group {
        flex-direction: column;
    }

    .btn-block {
        width: 100%;
    }
}

/* ============================================================================
   Utility Classes
   ============================================================================ */

.text-center { text-align: center; }
.text-right { text-align: right; }
.text-primary { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-success { color: var(--success-color); }
.text-danger { color: var(--danger-color); }
.text-warning { color: var(--warning-color); }

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }

.hidden { display: none !important; }
.d-block { display: block; }
.d-flex { display: flex; }
.flex-1 { flex: 1; }
.ml-1 { margin-left: 0.5rem; }
.ml-2 { margin-left: 1rem; }

/* Help target styling */
.help-target {
    position: relative;
}

/* Section titles */
.section-title {
    margin-bottom: 1rem;
    color: var(--primary-color);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.subsection-title {
    margin: 1.5rem 0 1rem;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Panel header with help button */
.panel-header {
    position: relative;
}

.panel-header .contextual-help-btn {
    position: static;
    margin-left: auto;
}

.card-header .contextual-help-btn {
    position: static;
    margin-left: auto;
}

/* ============================================================================
   Help System
   ============================================================================ */

/* Help Trigger Button */
.help-trigger {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    margin-left: 1rem;
}

.help-trigger:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

/* Help Panel */
.help-panel {
    position: fixed;
    top: 0;
    right: -400px;
    width: 400px;
    height: 100vh;
    background: var(--card-bg);
    box-shadow: -5px 0 25px rgba(0, 0, 0, 0.15);
    z-index: 10000;
    transition: right 0.3s ease;
    display: flex;
    flex-direction: column;
}

.help-panel.open {
    right: 0;
}

.help-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
}

.help-panel-header h3 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
}

.help-close-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.help-close-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Help Navigation */
.help-panel-nav {
    display: flex;
    border-bottom: 1px solid var(--border-color);
}

.help-nav-btn {
    flex: 1;
    padding: 0.75rem;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 0.875rem;
    color: var(--text-secondary);
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.help-nav-btn:hover {
    background: var(--bg-color);
    color: var(--primary-color);
}

.help-nav-btn.active {
    color: var(--primary-color);
    border-bottom: 2px solid var(--primary-color);
    margin-bottom: -1px;
}

/* Help Search */
.help-panel-search {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    position: relative;
}

.help-panel-search input {
    width: 100%;
    padding: 0.75rem 1rem 0.75rem 2.5rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius);
    font-size: 0.9rem;
}

.help-panel-search input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.help-panel-search i {
    position: absolute;
    left: 1.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
}

/* Help Content */
.help-panel-content {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
}

.help-topics {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.help-section-title {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    margin: 1rem 0 0.5rem;
    padding-left: 0.5rem;
}

.help-topic-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: var(--bg-color);
    border-radius: var(--radius);
    cursor: pointer;
    transition: var(--transition);
}

.help-topic-item:hover {
    background: var(--border-color);
}

.help-topic-item i:first-child {
    color: var(--primary-color);
    width: 20px;
}

.help-topic-item span {
    flex: 1;
    font-size: 0.9rem;
}

.help-topic-item i:last-child {
    color: var(--text-secondary);
    font-size: 0.75rem;
}

/* Help Topic Detail */
.help-topic-detail {
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateX(10px); }
    to { opacity: 1; transform: translateX(0); }
}

.help-back-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    margin-bottom: 1rem;
    border: none;
    background: var(--bg-color);
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.875rem;
    color: var(--text-secondary);
    transition: var(--transition);
}

.help-back-btn:hover {
    background: var(--border-color);
    color: var(--primary-color);
}

.help-topic-detail h4 {
    color: var(--primary-color);
    margin-bottom: 1rem;
    font-size: 1.25rem;
}

.help-topic-content {
    font-size: 0.9rem;
    line-height: 1.7;
    color: var(--text-primary);
}

.help-topic-content h5 {
    color: var(--text-primary);
    margin: 1rem 0 0.5rem;
    font-size: 1rem;
}

.help-topic-content p {
    margin-bottom: 0.75rem;
}

.help-topic-content ul, .help-topic-content ol {
    margin: 0.5rem 0 1rem 1.5rem;
}

.help-topic-content li {
    margin-bottom: 0.25rem;
}

.help-topic-content pre {
    background: #1e1e1e;
    color: #d4d4d4;
    padding: 1rem;
    border-radius: var(--radius);
    overflow-x: auto;
    font-size: 0.8rem;
    margin: 0.5rem 0;
}

.help-topic-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 0.5rem 0;
}

.help-topic-content th, .help-topic-content td {
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    text-align: left;
}

.help-topic-content th {
    background: var(--bg-color);
    font-weight: 600;
}

.help-topic-content kbd {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-family: monospace;
    font-size: 0.85em;
}

/* Help Search Results */
.help-search-results {
    animation: fadeIn 0.2s ease;
}

.help-results-count {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.help-no-results {
    text-align: center;
    padding: 2rem;
    color: var(--text-secondary);
}

.help-no-results i {
    font-size: 2rem;
    margin-bottom: 1rem;
    display: block;
}

/* Contextual Help Button */
.contextual-help-btn {
    position: absolute;
    top: 0;
    right: 0;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.25rem;
    font-size: 1rem;
    transition: var(--transition);
    opacity: 0.5;
}

.contextual-help-btn:hover {
    color: var(--primary-color);
    opacity: 1;
}

/* Help Tooltip */
.help-tooltip {
    position: absolute;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 1rem;
    max-width: 300px;
    box-shadow: var(--shadow-lg);
    z-index: 10001;
    animation: fadeIn 0.2s ease;
}

.help-tooltip h5 {
    color: var(--primary-color);
    margin-bottom: 0.5rem;
    font-size: 0.95rem;
}

.help-tooltip-content {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* Tour Elements */
.tour-highlight {
    position: absolute;
    border: 3px solid var(--primary-color);
    border-radius: var(--radius);
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.5);
    z-index: 10002;
    pointer-events: none;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.5), 0 0 0 0 rgba(8, 145, 178, 0.4); }
    50% { box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.5), 0 0 0 10px rgba(8, 145, 178, 0); }
}

.tour-tooltip {
    position: absolute;
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 1.5rem;
    max-width: 350px;
    box-shadow: var(--shadow-lg);
    z-index: 10003;
    animation: fadeIn 0.3s ease;
}

.tour-tooltip-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.tour-step-indicator {
    background: var(--primary-color);
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
}

.tour-tooltip h4 {
    margin: 0;
    color: var(--text-primary);
}

.tour-tooltip p {
    color: var(--text-secondary);
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

.tour-tooltip-buttons {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

/* Responsive Help Panel */
@media (max-width: 480px) {
    .help-panel {
        width: 100%;
        right: -100%;
    }
}
