:root {
    --bg-color: #0f172a;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --glass-bg: rgba(30, 41, 59, 0.7);
    --glass-border: rgba(255, 255, 255, 0.1);
    --accent-color: #3b82f6;
    --accent-hover: #2563eb;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    min-height: 100vh;
    position: relative;
    overflow-x: hidden;
}

.background-blobs {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    z-index: -1;
    background: 
        radial-gradient(circle at 15% 50%, rgba(59, 130, 246, 0.15) 0%, transparent 50%),
        radial-gradient(circle at 85% 30%, rgba(16, 185, 129, 0.15) 0%, transparent 50%);
    filter: blur(80px);
}

.container {
    max-width: 1920px;
    width: 96%;
    margin: 0 auto;
    padding: 2rem 0;
}

.glass-panel, .dashboard-sidebar, .dashboard-main {
    position: relative;
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
    z-index: 1;
}

.glass-panel::before, .dashboard-sidebar::before, .dashboard-main::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    z-index: -1;
}

.glass-panel {
    padding: 1.5rem;
}

header {
    margin-bottom: 2rem;
}

.header-content {
    display: flex;
    justify-content: space-around;
    align-items: center;
}

.stat {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.stat .label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
}

.stat .value {
    font-size: 2rem;
    font-weight: 600;
    color: var(--text-primary);
}

h2 {
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
}

.dashboard-layout {
    display: grid;
    grid-template-columns: 350px 1fr;
    gap: 1.5rem;
    margin-bottom: 3rem;
    min-height: 600px;
}

@media (max-width: 900px) {
    .dashboard-layout {
        grid-template-columns: 1fr;
    }
    .dashboard-sidebar-container {
        max-height: none !important;
        gap: 1.5rem;
    }
    .sidebar-holdings, .sidebar-news {
        max-height: 450px !important;
        flex: none;
    }
}

.dashboard-sidebar-container {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    max-height: 950px;
}

.sidebar-holdings {
    flex: 3;
    max-height: 520px;
}

.sidebar-news {
    flex: 2.5;
    max-height: 430px; /* Increased height limit to make the news box larger in y-led */
}

.dashboard-sidebar {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    max-height: 800px;
}

.dashboard-sidebar h3 {
    margin-bottom: 0.5rem;
    font-size: 1.25rem;
    color: var(--text-primary);
    border-bottom: 1px solid var(--glass-border);
    padding-bottom: 0.75rem;
}

.stock-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    overflow-y: auto;
    flex: 1;
    padding-right: 0.5rem;
}

.stock-list::-webkit-scrollbar {
    width: 6px;
}
.stock-list::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.2);
    border-radius: 3px;
}

.stock-item {
    padding: 1rem;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.stock-item:hover, .stock-item.active {
    background: rgba(59, 130, 246, 0.15);
    border-color: var(--accent-color);
    transform: translateX(4px);
}

.stock-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.stock-item-symbol {
    font-weight: 600;
    font-size: 1.1rem;
}

.stock-item-price {
    font-weight: 600;
    color: var(--success);
}

.stock-item-subtitle {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.dashboard-main {
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    min-width: 0; /* Allows the main block to shrink in CSS Grid */
}

.empty-state {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-secondary);
    font-size: 1.1rem;
    font-style: italic;
}

.detail-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    border-bottom: 1px solid var(--glass-border);
    padding-bottom: 1rem;
    flex-wrap: wrap; /* Allows header title and price to wrap on narrow viewports */
    gap: 1rem;
}

.active-orders-display {
    margin: 1rem 0;
    padding: 1rem;
    border-radius: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255,255,255,0.02);
    border: 1px solid rgba(255,255,255,0.05);
    z-index: 1;
    flex-wrap: wrap; /* Responsive wrapping on desktop sizing */
    gap: 1rem;
}

.detail-title h3 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

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

.detail-price {
    font-size: 2.5rem;
    font-weight: 600;
    color: var(--success);
}

.chart-container {
    position: relative;
    width: 100%;
    height: 450px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.analysis-box {
    background: rgba(30, 41, 59, 0.45);
    border-radius: 16px;
    padding: 1.75rem 2.25rem;
    font-size: 0.98rem;
    line-height: 1.75;
    color: #e2e8f0;
    border: 1px solid rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    margin-top: 1.5rem;
    transition: all 0.3s ease;
}

/* Specific styling for batch analysis */
.analysis-box.batch-analysis {
    margin-top: 1.5rem;
    background: rgba(16, 185, 129, 0.04);
    border: 1px solid rgba(16, 185, 129, 0.15);
    box-shadow: 0 10px 40px rgba(16, 185, 129, 0.05);
}

/* Markdown styling inside analysis-box */
.analysis-box h1 {
    font-size: 1.6rem;
    color: #ffffff;
    margin-top: 1.75rem;
    margin-bottom: 0.85rem;
    font-weight: 600;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    padding-bottom: 0.5rem;
    letter-spacing: -0.01em;
}

.analysis-box h2 {
    font-size: 1.35rem;
    color: var(--accent-color);
    margin-top: 1.6rem;
    margin-bottom: 0.75rem;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.analysis-box h3 {
    font-size: 1.15rem;
    color: var(--success);
    margin-top: 1.35rem;
    margin-bottom: 0.6rem;
    font-weight: 600;
}

.analysis-box h1:first-child, 
.analysis-box h2:first-child, 
.analysis-box h3:first-child {
    margin-top: 0;
}

.analysis-box p {
    margin-bottom: 1.25rem;
    color: #cbd5e1;
}

.analysis-box strong {
    color: #ffffff;
    font-weight: 600;
}

.analysis-box ul, 
.analysis-box ol {
    margin-left: 1.75rem;
    margin-bottom: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.analysis-box li {
    color: #cbd5e1;
    line-height: 1.7;
}

.analysis-box li strong {
    color: #ffffff;
}

.analysis-box blockquote {
    border-left: 4px solid var(--accent-color);
    background: rgba(59, 130, 246, 0.05);
    padding: 0.85rem 1.25rem;
    margin-bottom: 1.25rem;
    border-radius: 0 8px 8px 0;
    font-style: italic;
    color: #94a3b8;
}

.analysis-box code {
    font-family: 'Courier New', Courier, monospace;
    background: rgba(0, 0, 0, 0.3);
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    font-size: 0.9em;
    color: #f43f5e;
}

.analysis-box table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
    margin-bottom: 1.5rem;
    font-size: 0.95rem;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 8px;
    overflow: hidden;
}

.analysis-box th, 
.analysis-box td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.analysis-box th {
    font-weight: 600;
    color: var(--accent-color);
    background: rgba(0, 0, 0, 0.2);
}

.analysis-box tr:last-child td {
    border-bottom: none;
}

.analysis-box tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

.glass-btn {
    background: var(--accent-color);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
    margin-bottom: 1.5rem;
    box-shadow: 0 4px 14px rgba(59, 130, 246, 0.4);
}

.glass-btn:hover {
    background: var(--accent-hover);
    transform: translateY(-2px);
}
.glass-btn:active {
    transform: translateY(0);
}
.glass-btn:disabled {
    background: var(--text-secondary);
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

.loading-spinner {
    display: inline-block;
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255,255,255,.1);
    border-radius: 50%;
    border-top-color: var(--accent-color);
    animation: spin 1s ease-in-out infinite;
    margin: 2rem auto;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Header Actions */
.header-actions {
    display: flex;
    justify-content: center;
    gap: 2rem;
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--glass-border);
    flex-wrap: wrap;
}

.action-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.glass-input {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--glass-border);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.2s;
    width: 120px;
}
.glass-input:focus {
    border-color: var(--accent-color);
}

.glass-btn.small {
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
    margin-bottom: 0;
}

.upload-label {
    display: inline-block;
    cursor: pointer;
    background: rgba(16, 185, 129, 0.8);
    box-shadow: 0 4px 14px rgba(16, 185, 129, 0.3);
    margin-bottom: 0;
}
.upload-label:hover {
    background: rgba(16, 185, 129, 1);
}

/* Modal overlay styling */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
    animation: fadeIn 0.2s ease-out;
}

/* Modal Content Card */
.modal-content {
    width: 90%;
    max-width: 500px;
    padding: 2rem;
    border-radius: 16px;
    border: 1px solid var(--glass-border);
    animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

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

.modal-header h3 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 600;
    background: linear-gradient(135deg, #fff 0%, #cbd5e1 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.close-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    transition: color 0.2s;
}

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

/* Form Styles */
.modal-form {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

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

.form-group label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.modal-form .glass-input {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 1rem;
}

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

/* Beautiful Radio Card buttons */
.radio-cards {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 0.5rem;
}

.radio-card {
    position: relative;
    cursor: pointer;
    display: block;
}

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

.radio-card .card-content {
    display: flex;
    flex-direction: column;
    padding: 0.75rem;
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    background: rgba(0,0,0,0.2);
    transition: all 0.2s ease;
    text-align: center;
}

.radio-card:hover .card-content {
    background: rgba(255,255,255,0.05);
    border-color: rgba(255,255,255,0.2);
}

.radio-card input[type="radio"]:checked + .card-content {
    background: rgba(59, 130, 246, 0.15);
    border-color: var(--accent-color);
    box-shadow: 0 0 12px rgba(59, 130, 246, 0.2);
}

.card-title {
    font-weight: 600;
    font-size: 1rem;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.card-desc {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* Holdings Radio List */
.holdings-list-container {
    max-height: 120px;
    overflow-y: auto;
    border: 1px solid var(--glass-border);
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    padding: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.holdings-list-container::-webkit-scrollbar {
    width: 4px;
}
.holdings-list-container::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.2);
    border-radius: 2px;
}

.holding-radio-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s;
    font-size: 0.9rem;
    color: var(--text-primary);
}

.holding-radio-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.holding-radio-item input[type="radio"] {
    accent-color: var(--accent-color);
}

/* Modal Actions */
.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    margin-top: 1rem;
    border-top: 1px solid var(--glass-border);
    padding-top: 1rem;
}

.glass-btn.secondary {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    box-shadow: none;
}
.glass-btn.secondary:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* Chart Timeframe Selector styling */
.chart-timeframe-selector {
    display: flex;
    justify-content: flex-start;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    flex-wrap: wrap;
    background: rgba(0, 0, 0, 0.15);
    padding: 4px;
    border-radius: 10px;
    border: 1px solid var(--glass-border);
    width: fit-content;
}

.timeframe-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    padding: 0.35rem 0.75rem;
    font-size: 0.85rem;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s ease;
}

.timeframe-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.timeframe-btn.active {
    color: #ffffff;
    background: var(--accent-color);
    box-shadow: 0 2px 10px rgba(59, 130, 246, 0.3);
}

/* Marknadsnyheter News Items Styling */
.news-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    padding: 0.75rem;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    text-decoration: none;
    transition: all 0.2s ease;
}

.news-item:hover {
    background: rgba(59, 130, 246, 0.1);
    border-color: rgba(59, 130, 246, 0.4);
    transform: translateX(4px);
}

.news-item-title {
    font-size: 0.85rem;
    font-weight: 500;
    line-height: 1.4;
    color: var(--text-primary);
}

.news-item:hover .news-item-title {
    color: #60a5fa; /* Light blue on hover */
}

.news-item-meta {
    font-size: 0.7rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.news-item-link-icon {
    color: var(--accent-color);
    font-weight: 600;
}

/* Pixel 8 Pro & Smartphone Responsiveness */
@media (max-width: 600px) {
    .container {
        width: 100%;
        padding: 1rem 0.5rem;
    }
    
    .header-content {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
        gap: 0.75rem;
    }
    
    .stat {
        padding: 0.5rem;
        background: rgba(0, 0, 0, 0.1);
        border-radius: 8px;
        border: 1px solid rgba(255, 255, 255, 0.02);
    }
    
    .stat .label {
        font-size: 0.7rem;
        margin-bottom: 0.25rem;
    }
    
    .stat .value {
        font-size: 1.25rem;
    }
    
    .header-actions {
        flex-direction: column;
        gap: 0.75rem;
        align-items: stretch;
        margin-top: 1rem;
        padding-top: 1rem;
    }
    
    .action-group {
        width: 100%;
        justify-content: center;
    }
    
    .action-group .glass-input {
        flex: 1;
        width: auto;
    }
    
    .dashboard-sidebar-container {
        max-height: none !important;
        gap: 1rem !important;
    }
    
    .dashboard-sidebar {
        max-height: 380px !important;
        padding: 1rem !important;
    }
    
    .dashboard-sidebar h3 {
        font-size: 1.1rem;
        padding-bottom: 0.5rem;
    }
    
    .dashboard-main {
        padding: 1rem !important;
        gap: 1rem !important;
    }
    
    .detail-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    
    .detail-title h3 {
        font-size: 1.5rem;
    }
    
    .detail-price {
        font-size: 1.75rem;
    }
    
    .chart-container {
        height: 280px !important;
    }
    
    .chart-timeframe-selector {
        width: 100%;
        justify-content: space-between;
        gap: 2px;
        padding: 2px;
    }
    
    .timeframe-btn {
        padding: 0.25rem 0.4rem;
        font-size: 0.75rem;
        flex: 1;
        text-align: center;
    }
    
    .active-orders-display {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 0.75rem;
    }
    
    .active-orders-display button {
        width: 100%;
    }
    
    /* Modals & Forms mobile styling */
    .modal-content {
        width: 95% !important;
        padding: 1.25rem !important;
    }
    
    .modal-header h3 {
        font-size: 1.25rem;
    }
    
    .form-grid {
        grid-template-columns: 1fr !important;
        gap: 0.75rem;
    }
    
    .radio-cards {
        grid-template-columns: 1fr !important;
        gap: 0.5rem;
    }
    
    .radio-card .card-content {
        padding: 0.5rem;
    }
    
    .card-title {
        font-size: 0.9rem;
    }
}

/* Fullskärms- och sida-vid-sida-optimering för desktop (t.ex. 2560x1440) */
@media (min-width: 1600px) {
    .container {
        max-width: 2500px;
        width: 98%;
        padding: 1.5rem 0;
    }

    /* 4-kolumnslayout för Portföljen på en rad - AI-analys satt till 600px, Grafen tar resten */
    #portfolio-layout-wrapper {
        display: grid;
        grid-template-columns: 340px 1fr 600px 280px;
        gap: 1.5rem;
        margin-bottom: 2rem;
        height: 650px; /* Fast höjd på raden för perfekt linjering */
        align-items: stretch;
        transition: height 0.3s ease;
    }

    /* 3-kolumnslayout för Kandidater på en rad - AI-analys satt till 600px, Grafen tar resten */
    #candidates-layout-wrapper {
        display: grid;
        grid-template-columns: 340px 1fr 600px;
        gap: 1.5rem;
        margin-bottom: 2rem;
        height: 380px; /* Fast höjd för kandidatraden */
        align-items: stretch;
    }

    /* Siduppdelning när kandidater är expanderade */
    main.candidates-expanded {
        display: grid;
        grid-template-rows: auto auto;
        gap: 2rem;
    }

    /* Minska portföljradens höjd till 380px när kandidatraden öppnas */
    main.candidates-expanded #portfolio-layout-wrapper {
        height: 380px;
    }

    /* Gör så att alla paneler sträcker sig till 100% av radens höjd */
    .dashboard-sidebar, .dashboard-main, .analysis-box-container {
        height: 100%;
        max-height: 100%;
        min-height: 0;
    }

    /* Gör graf-panelen till en flexbox så att själva grafen fyller ut resterande utrymme */
    .dashboard-main {
        display: flex;
        flex-direction: column;
    }

    /* Gör så att graf-behållaren tar upp all tillgänglig höjd i panelen */
    .chart-container {
        flex: 1;
        height: auto !important; /* Låt flexboxen styra höjden! */
        min-height: 0;
    }

    .analysis-box-container {
        display: flex;
        flex-direction: column;
    }

    .analysis-box-container .analysis-box {
        flex: 1;
        height: 100%;
        max-height: 100%;
        overflow-y: auto;
        margin-top: 0;
        padding-right: 0.5rem;
    }

    /* Scrollbar-styling för AI-analysboxen på desktop */
    .analysis-box::-webkit-scrollbar {
        width: 6px;
    }
    .analysis-box::-webkit-scrollbar-thumb {
        background: rgba(255,255,255,0.2);
        border-radius: 3px;
    }
}

