/* Aktie Dashboard - Stylesheet */

:root {
    --primary: #1a2332;
    --primary-light: #2d3e50;
    --accent: #3498db;
    --accent-hover: #2980b9;
    --success: #27ae60;
    --success-light: #2ecc71;
    --danger: #e74c3c;
    --danger-light: #ff6b6b;
    --warning: #f39c12;
    --bg: #f5f7fa;
    --card-bg: #ffffff;
    --text: #2c3e50;
    --text-muted: #7f8c8d;
    --border: #e0e6ed;
    --shadow: 0 2px 8px rgba(0,0,0,0.08);
    --radius: 8px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
}

/* Navbar */
.navbar {
    background: var(--primary);
    color: #fff;
    padding: 0 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 56px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-brand a {
    color: #fff;
    text-decoration: none;
    font-size: 1.2rem;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.nav-links a {
    color: rgba(255,255,255,0.75);
    text-decoration: none;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius);
    font-size: 0.9rem;
    transition: all 0.2s;
}

.nav-links a:hover, .nav-links a.active {
    color: #fff;
    background: rgba(255,255,255,0.1);
}

.nav-user {
    color: rgba(255,255,255,0.6);
    font-size: 0.85rem;
    margin-left: 1rem;
    padding-right: 0.5rem;
    border-right: 1px solid rgba(255,255,255,0.2);
    padding-left: 0.5rem;
}

.btn-logout {
    color: var(--danger-light) !important;
}

/* Container */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1.5rem 2rem;
}

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

.page-header h1 {
    font-size: 1.6rem;
    color: var(--primary);
}

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

.back-link {
    display: block;
    color: var(--accent);
    text-decoration: none;
    font-size: 0.85rem;
    margin-bottom: 0.3rem;
}

.back-link:hover { text-decoration: underline; }

/* Cards */
.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    border: 1px solid var(--border);
}

.card h2 {
    font-size: 1.2rem;
    margin-bottom: 1rem;
    color: var(--primary);
}

.card h3 {
    font-size: 1.05rem;
    color: var(--primary);
}

/* Summary Cards */
.summary-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.summary-card {
    text-align: center;
    padding: 1.25rem;
}

.card-label {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    margin-bottom: 0.3rem;
}

.card-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
}

/* Depot Grid */
.depot-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1rem;
}

.depot-card {
    text-decoration: none;
    color: inherit;
    transition: transform 0.2s, box-shadow 0.2s;
    cursor: pointer;
}

.depot-card-header h3 {
    font-size: 1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 220px;
}

.depot-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0,0,0,0.12);
}

.depot-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
}

.depot-card-body {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.depot-stat {
    display: flex;
    justify-content: space-between;
}

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

.stat-value {
    font-weight: 600;
}

.depot-card-footer {
    margin-top: 1rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Depot groups */
.group-header {
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--border);
}

.group-header h2 {
    font-size: 1.1rem;
    color: var(--primary);
    margin-bottom: 0.3rem;
}

.group-summary {
    display: flex;
    gap: 1.2rem;
    font-size: 0.8rem;
    color: var(--text-muted);
    flex-wrap: wrap;
}

/* Gain/Loss */
.gain-positive { color: var(--success) !important; }
.gain-negative { color: var(--danger) !important; }

/* Badges */
.badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    background: var(--bg);
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-small {
    padding: 0.1rem 0.4rem;
    font-size: 0.7rem;
}

.badge-buy { background: #e8f5e9; color: var(--success); }
.badge-sell { background: #ffebee; color: var(--danger); }
.badge-admin { background: #e3f2fd; color: var(--accent); }
.badge-user { background: var(--bg); color: var(--text-muted); }

.currency-tag {
    background: var(--primary);
    color: #fff;
    padding: 0.15rem 0.5rem;
    border-radius: 3px;
    font-size: 0.7rem;
    font-weight: 700;
}

/* Tables */
.table-responsive {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th {
    text-align: left;
    padding: 0.5rem 0.4rem;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    color: var(--text-muted);
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
    user-select: none;
}

.data-table th:hover {
    color: var(--primary);
}

.data-table td {
    padding: 0.5rem 0.4rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.85rem;
}

.data-table tbody tr:hover {
    background: rgba(52, 152, 219, 0.04);
}

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

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.5rem 1.2rem;
    border: none;
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s;
    line-height: 1.4;
}

.btn:hover { opacity: 0.85; }

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-secondary { background: var(--border); color: var(--text); }
.btn-block { display: block; width: 100%; text-align: center; }
.btn-small { padding: 0.3rem 0.7rem; font-size: 0.8rem; }

/* Forms */
.form-card { max-width: 700px; }

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

.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.3rem;
    font-size: 0.9rem;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.6rem 0.8rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.95rem;
    font-family: inherit;
    transition: border-color 0.2s;
    background: #fff;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.15);
}

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

.form-hint {
    display: block;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.2rem;
}

.form-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1.5rem;
}

.checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: normal !important;
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    width: auto;
}

/* Alerts */
.alert {
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-size: 0.9rem;
    transition: opacity 0.3s;
}

.alert-success { background: #e8f5e9; color: #2e7d32; border: 1px solid #c8e6c9; }
.alert-error { background: #ffebee; color: #c62828; border: 1px solid #ffcdd2; }
.alert-info { background: #e3f2fd; color: #1565c0; border: 1px solid #bbdefb; }

/* Login */
.login-page {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
}

.login-container {
    background: var(--card-bg);
    padding: 2.5rem;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
    width: 100%;
    max-width: 400px;
}

.login-container h1 {
    text-align: center;
    color: var(--primary);
    margin-bottom: 1.5rem;
    font-size: 1.6rem;
}

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

.empty-state p { margin-bottom: 1rem; }

/* Filter Bar */
.filter-bar {
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.filter-bar label {
    font-weight: 600;
    font-size: 0.9rem;
}

.filter-bar select {
    padding: 0.4rem 0.8rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.9rem;
}

/* Analyses */
.analyses-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.analysis-card { border-left: 4px solid var(--accent); }

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

.analysis-meta {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    margin-top: 0.3rem;
    flex-wrap: wrap;
}

.analysis-date {
    color: var(--text-muted);
    font-size: 0.85rem;
    white-space: nowrap;
}

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

/* Import Results */
.import-results {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.result-stat { padding: 0.75rem; border-radius: var(--radius); }
.result-success { background: #e8f5e9; color: #2e7d32; }
.result-skipped { background: #fff3e0; color: #e65100; }
.result-errors { background: #ffebee; color: #c62828; }
.result-errors ul { margin-top: 0.5rem; padding-left: 1.5rem; }

/* Danger Zone */
.danger-zone {
    border: 1px solid var(--danger);
    border-left: 4px solid var(--danger);
}

.danger-zone h3 {
    color: var(--danger);
    margin-bottom: 0.75rem;
}

/* Inline form */
.inline-form { display: inline; }

/* AI Badges */
.ai-badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 700;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.ai-badge-buy  { background: #e8f5e9; color: var(--success); }
.ai-badge-hold { background: #fff8e1; color: #f57f17; }
.ai-badge-sell { background: #ffebee; color: var(--danger); }

.ai-badge:hover { opacity: 0.85; }

.tooltip-date {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-style: italic;
}

.confidence-score {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--accent);
    margin-left: 0.3rem;
}

/* AI Tooltip */
.ai-tooltip {
    display: none;
    position: fixed;
    z-index: 1000;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
    padding: 0.75rem;
    width: 320px;
    font-size: 0.8rem;
    line-height: 1.5;
    white-space: normal;
    text-align: left;
}

/* Symbol chart tooltip */
.symbol-link {
    position: relative;
}

.symbol-tooltip {
    display: none;
    position: fixed;
    z-index: 1000;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
    padding: 0;
    width: 500px;
    height: 320px;
    overflow: hidden;
}

.symbol-tooltip iframe {
    width: 100%;
    height: 100%;
    border: none;
}

/* tooltips positioned via JS */

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

.modal-content {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 2rem;
    max-width: 700px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}

.modal-close {
    position: absolute;
    top: 0.75rem;
    right: 1rem;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-muted);
}

.modal-close:hover { color: var(--text); }

/* Summary tooltip (yearly realized) */
.summary-tooltip {
    display: none;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    top: 100%;
    z-index: 50;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
    padding: 0.75rem 1rem;
    min-width: 200px;
    font-size: 0.85rem;
    white-space: nowrap;
}

.summary-card:hover .summary-tooltip {
    display: block;
}

.summary-tooltip strong {
    display: block;
    margin-bottom: 0.4rem;
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--text-muted);
}

.yearly-row {
    display: flex;
    justify-content: space-between;
    gap: 1.5rem;
    padding: 0.15rem 0;
    border-bottom: 1px solid var(--border);
}

.yearly-row:last-child { border-bottom: none; }

/* Unrealized toggle */
.unrealized-toggle {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-bottom: 0.75rem;
}

.toggle-btn {
    padding: 0.25rem 0.6rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--card-bg);
    font-size: 0.8rem;
    cursor: pointer;
    color: var(--text-muted);
    transition: all 0.15s;
}

.toggle-btn:hover { border-color: var(--accent); color: var(--accent); }
.toggle-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* Stock chart modal */
#stock-modal .modal-content {
    max-height: none;
    overflow: hidden;
}

.symbol-link {
    color: var(--primary);
    cursor: pointer;
    text-decoration: none;
}
.symbol-link:hover {
    text-decoration: underline;
    color: var(--accent);
}

.modal-content h2 { margin-bottom: 0.5rem; }
.modal-content h4 { margin-top: 1rem; margin-bottom: 0.3rem; color: var(--primary); }
.modal-content p { margin-bottom: 0.5rem; }
.modal-content hr { border: none; border-top: 1px solid var(--border); margin: 1rem 0; }

/* Card header row */
.card-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.card-header-row h2 { margin-bottom: 0; }

.text-small { font-size: 0.8rem; }

.depot-review-card {
    border: 1px solid var(--border);
    border-left: 4px solid var(--accent);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    margin-bottom: 1rem;
}

.depot-review-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.75rem;
}

.depot-review-header h3 { margin: 0; }
.depot-review-header h3 a { color: var(--primary); text-decoration: none; }
.depot-review-header h3 a:hover { text-decoration: underline; }

.depot-review-body {
    font-size: 0.9rem;
    line-height: 1.7;
    margin-bottom: 0.75rem;
}

.depot-review-action {
    background: #e8f5e9;
    padding: 0.6rem 0.8rem;
    border-radius: var(--radius);
    font-size: 0.85rem;
    color: #2e7d32;
}

.depot-purpose {
    font-size: 0.9rem;
    color: var(--accent);
    font-style: italic;
    margin-top: 0.2rem;
}

/* Autocomplete */
.autocomplete-wrapper {
    position: relative;
}

.autocomplete-results {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-top: none;
    border-radius: 0 0 var(--radius) var(--radius);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    max-height: 320px;
    overflow-y: auto;
    z-index: 50;
}

.autocomplete-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.6rem 0.8rem;
    cursor: pointer;
    border-bottom: 1px solid var(--border);
    transition: background 0.1s;
}

.autocomplete-item:last-child { border-bottom: none; }
.autocomplete-item:hover,
.autocomplete-item.active {
    background: rgba(52, 152, 219, 0.08);
}

.ac-symbol {
    font-weight: 700;
    font-size: 0.9rem;
    min-width: 90px;
    color: var(--primary);
}

.ac-name {
    flex: 1;
    font-size: 0.85rem;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ac-exchange {
    flex-shrink: 0;
}

.autocomplete-empty {
    padding: 0.75rem;
    color: var(--text-muted);
    font-size: 0.85rem;
    text-align: center;
}

.input-with-hint {
    display: flex;
    flex-direction: column;
}

.input-with-hint input {
    width: 100%;
}

/* Settings / Nordnet */
.form-card-wide { max-width: 800px; }

.status-box {
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
}

.status-connected {
    background: #e8f5e9;
    color: #2e7d32;
    border: 1px solid #c8e6c9;
}

.monospace {
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 0.85rem;
}

code {
    background: var(--bg);
    padding: 0.15rem 0.4rem;
    border-radius: 3px;
    font-size: 0.85rem;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
}

/* Responsive */
@media (max-width: 768px) {
    .navbar {
        flex-direction: column;
        height: auto;
        padding: 0.75rem 1rem;
        gap: 0.5rem;
    }

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

    .container { padding: 1rem; }

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

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

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

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

    .nav-user {
        display: none;
    }
}
