@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Outfit:wght@400;500;600;700;800&display=swap');

/* CSS Variables for Premium Dark Glassmorphism Theme */
:root {
    --bg-primary: #0A0D16;
    --bg-secondary: #0F1322;
    --bg-card: rgba(22, 28, 45, 0.45);
    --bg-card-hover: rgba(30, 37, 58, 0.6);
    --bg-input: #151B2D;
    --bg-input-focus: #1A223B;
    
    --border-color: rgba(255, 255, 255, 0.06);
    --border-hover: rgba(255, 255, 255, 0.12);
    --border-focus: #6366F1;
    
    --text-primary: #F9FAFB;
    --text-secondary: #9CA3AF;
    --text-muted: #6B7280;
    
    /* Accents & Gradients */
    --accent-indigo: #6366F1;
    --accent-purple: #8B5CF6;
    --accent-cyan: #06B6D4;
    --accent-emerald: #10B981;
    --accent-rose: #F43F5E;
    --accent-amber: #F59E0B;
    
    --gradient-primary: linear-gradient(135deg, #6366F1 0%, #8B5CF6 100%);
    --gradient-emerald: linear-gradient(135deg, #10B981 0%, #059669 100%);
    --gradient-rose: linear-gradient(135deg, #F43F5E 0%, #E11D48 100%);
    --gradient-glow: radial-gradient(circle, rgba(99, 102, 241, 0.15) 0%, rgba(139, 92, 246, 0.05) 50%, rgba(0, 0, 0, 0) 100%);
    
    --card-shadow: 0 12px 40px 0 rgba(0, 0, 0, 0.5);
    --card-blur: blur(16px);
    
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --font-heading: 'Outfit', sans-serif;
    --font-body: 'Inter', sans-serif;
}

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

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

body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-family: var(--font-body);
    line-height: 1.5;
    overflow-x: hidden;
    position: relative;
    min-height: 100vh;
}

/* Glow Elements */
.bg-glow {
    position: fixed;
    width: 600px;
    height: 600px;
    border-radius: 50%;
    background: var(--gradient-glow);
    filter: blur(80px);
    pointer-events: none;
    z-index: -1;
    opacity: 0.8;
}

.glow-top-right {
    top: -200px;
    right: -100px;
}

.glow-bottom-left {
    bottom: -200px;
    left: -100px;
}

/* Scrollbar Styles */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: var(--bg-primary);
}
::-webkit-scrollbar-thumb {
    background: var(--bg-input);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--border-hover);
}

/* App Container Layout */
.app-container {
    max-width: 1440px;
    margin: 0 auto;
    padding: 2rem;
}

/* Header */
.main-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 1.5rem;
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo-icon {
    width: 36px;
    height: 36px;
    background: var(--gradient-primary);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4);
}

.logo-text {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    font-weight: 800;
    background: linear-gradient(135deg, #FFF 30%, #A855F7 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

/* 2-Column Dashboard Grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1.15fr 0.85fr;
    gap: 2rem;
    align-items: start;
}

/* Left Column: Inputs & Management */
.input-col {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

/* Right Column: Visualization & Results (Sticky) */
.result-col {
    display: flex;
    flex-direction: column;
    gap: 2rem;
    position: sticky;
    top: 2rem;
    max-height: calc(100vh - 4rem);
    overflow-y: auto;
    padding-right: 0.5rem;
}

/* Premium Button Styling */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.7rem 1.2rem;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-smooth);
    border: 1px solid transparent;
    font-family: var(--font-body);
    font-size: 0.85rem;
}

.btn-primary {
    background: var(--gradient-primary);
    color: white;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.35);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.5);
}

.btn-secondary {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: var(--bg-input-focus);
    border-color: var(--border-hover);
}

.btn-danger {
    background: rgba(244, 63, 94, 0.1);
    border: 1px solid rgba(244, 63, 94, 0.2);
    color: var(--accent-rose);
}

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

.btn-success {
    background: var(--gradient-emerald);
    color: white;
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.3);
}

.btn-success:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.55);
}

/* Glassmorphism Card Style */
.card {
    background: var(--bg-card);
    backdrop-filter: var(--card-blur);
    -webkit-backdrop-filter: var(--card-blur);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 1.5rem;
    box-shadow: var(--card-shadow);
    transition: var(--transition-smooth);
}

.card:hover {
    border-color: var(--border-hover);
    background: var(--bg-card-hover);
}

.card-title-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
}

.card-title {
    font-family: var(--font-heading);
    font-size: 1.15rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* STATS BAR */
.stats-bar {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    border-radius: 12px;
}

.stat-info {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

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

.stat-value {
    font-family: var(--font-heading);
    font-size: 1.4rem;
    font-weight: 800;
}

.stat-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}

.stat-icon.indigo { background: rgba(99, 102, 241, 0.12); color: var(--accent-indigo); border: 1px solid rgba(99, 102, 241, 0.2); }
.stat-icon.emerald { background: rgba(16, 185, 129, 0.12); color: var(--accent-emerald); border: 1px solid rgba(16, 185, 129, 0.2); }
.stat-icon.purple { background: rgba(139, 92, 246, 0.12); color: var(--accent-purple); border: 1px solid rgba(139, 92, 246, 0.2); }

.stat-badge {
    align-self: flex-start;
    padding: 0.2rem 0.5rem;
    border-radius: 5px;
    font-size: 0.7rem;
    font-weight: 700;
    margin-top: 0.25rem;
}

.stat-badge.success { background: rgba(16, 185, 129, 0.12); color: var(--accent-emerald); }
.stat-badge.warning { background: rgba(245, 158, 11, 0.12); color: var(--accent-amber); }
.stat-badge.danger { background: rgba(244, 63, 94, 0.12); color: var(--accent-rose); }

/* ACCOUNTS SECTION */
.accounts-list {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.account-card {
    border-left: 4px solid var(--accent-indigo);
    background: rgba(22, 28, 45, 0.3);
}

.account-card.general { border-left-color: var(--accent-indigo); }
.account-card.isa { border-left-color: var(--accent-cyan); }
.account-card.pension { border-left-color: var(--accent-purple); }
.account-card.irp { border-left-color: var(--accent-amber); }
.account-card.cash { border-left-color: var(--accent-emerald); }

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

.account-meta {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-grow: 1;
}

.account-type-select {
    padding: 0.3rem 1.5rem 0.3rem 0.6rem;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 700;
    border: 1px solid var(--border-color);
    background-color: var(--bg-input);
    color: var(--text-primary);
    cursor: pointer;
    width: auto;
    height: auto;
}

/* DIY Input for Account Name */
.account-name-input {
    font-family: var(--font-heading);
    font-size: 1.1rem;
    font-weight: 700;
    background: transparent;
    border: 1px dashed transparent;
    color: var(--text-primary);
    padding: 0.2rem 0.5rem;
    border-radius: 6px;
    width: 200px;
    transition: var(--transition-smooth);
}

.account-name-input:hover {
    border-color: var(--border-hover);
    background: var(--bg-input);
}

.account-name-input:focus {
    outline: none;
    border-color: var(--border-focus);
    background: var(--bg-input-focus);
}

.account-total {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.account-total span {
    font-family: var(--font-heading);
    font-weight: 700;
    color: var(--text-primary);
}

/* Assets Table */
.asset-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1rem;
    text-align: left;
}

.asset-table th {
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--border-color);
}

.asset-table td {
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}

.asset-table tr:last-child td {
    border-bottom: none;
}

/* Table inputs */
.input-text {
    width: 100%;
    background-color: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 0.45rem 0.7rem;
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 0.85rem;
    transition: var(--transition-smooth);
}

.input-text:focus {
    outline: none;
    border-color: var(--border-focus);
    background-color: var(--bg-input-focus);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.select-custom {
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239CA3AF' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.6rem center;
    background-size: 0.8rem;
    padding-right: 1.8rem;
}

.col-name { width: 40%; }
.col-category { width: 25%; }
.col-amount { width: 27%; }
.col-actions { width: 8%; text-align: center; }

.btn-icon-delete {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    background: transparent;
    border: 1px solid transparent;
    cursor: pointer;
    transition: var(--transition-smooth);
}

.btn-icon-delete:hover {
    color: var(--accent-rose);
    background: rgba(244, 63, 94, 0.08);
    border-color: rgba(244, 63, 94, 0.2);
}

.account-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* TARGET ALLOCATION SLIDERS */
.target-grid {
    display: grid;
    grid-template-columns: 1.2fr 0.8fr;
    gap: 1.5rem;
}

.target-sliders {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.slider-group {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.slider-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
    font-weight: 500;
}

.slider-category-info {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.category-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.category-dot.safe { background-color: var(--accent-indigo); }
.category-dot.growth { background-color: var(--accent-purple); }
.category-dot.cash { background-color: var(--accent-emerald); }
.category-dot.pension { background-color: var(--accent-amber); }

.slider-value {
    font-family: var(--font-heading);
    font-weight: 700;
    color: var(--accent-indigo);
}

.range-input {
    width: 100%;
    -webkit-appearance: none;
    appearance: none;
    height: 5px;
    border-radius: 3px;
    background: var(--bg-input);
    outline: none;
    transition: var(--transition-smooth);
}

.range-input::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--accent-indigo);
    cursor: pointer;
    box-shadow: 0 0 8px rgba(99, 102, 241, 0.4);
    transition: var(--transition-smooth);
}

.range-input::-webkit-slider-thumb:hover {
    transform: scale(1.15);
}

.range-input.growth::-webkit-slider-thumb { background: var(--accent-purple); box-shadow: 0 0 8px rgba(139, 92, 246, 0.4); }
.range-input.cash::-webkit-slider-thumb { background: var(--accent-emerald); box-shadow: 0 0 8px rgba(16, 185, 129, 0.4); }
.range-input.pension::-webkit-slider-thumb { background: var(--accent-amber); box-shadow: 0 0 8px rgba(245, 158, 11, 0.4); }

.target-visualization {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    border-left: 1px solid var(--border-color);
    padding-left: 1.5rem;
}

.total-indicator {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    border: 6px solid var(--bg-input);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-family: var(--font-heading);
    transition: var(--transition-smooth);
}

.total-indicator.valid { border-color: rgba(16, 185, 129, 0.2); box-shadow: 0 0 20px rgba(16, 185, 129, 0.08) inset; }
.total-indicator.invalid { border-color: rgba(244, 63, 94, 0.2); box-shadow: 0 0 20px rgba(244, 63, 94, 0.08) inset; }

.total-percent {
    font-size: 1.8rem;
    font-weight: 850;
}

.total-percent.valid { color: var(--accent-emerald); }
.total-percent.invalid { color: var(--accent-rose); }

.total-status {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 600;
}

.presets-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
    width: 100%;
}

.preset-card {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.5rem;
    text-align: center;
    cursor: pointer;
    transition: var(--transition-smooth);
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.preset-card:hover {
    background: rgba(99, 102, 241, 0.1);
    border-color: var(--accent-indigo);
    color: white;
}

/* INVESTMENT CONTROL PANEL */
.investment-control-bar {
    display: flex;
    gap: 1.25rem;
    align-items: flex-end;
    flex-wrap: wrap;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.input-group label {
    font-size: 0.8rem;
    font-weight: 650;
    color: var(--text-secondary);
}

.mode-toggle-group {
    display: flex;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.2rem;
}

.mode-tab {
    padding: 0.45rem 1rem;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-smooth);
    color: var(--text-secondary);
}

.mode-tab.active {
    background: var(--accent-indigo);
    color: white;
    box-shadow: 0 4px 10px rgba(99, 102, 241, 0.25);
}

/* CHARTS CARD */
.charts-card {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.chart-item {
    height: 220px;
    position: relative;
    width: 100%;
}

/* REBALANCING TABLES & COMMITS */
.badge-action {
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 700;
}

.badge-action.buy { background: rgba(16, 185, 129, 0.12); color: var(--accent-emerald); }
.badge-action.sell { background: rgba(244, 63, 94, 0.12); color: var(--accent-rose); }
.badge-action.keep { background: rgba(107, 114, 128, 0.12); color: var(--text-secondary); }

/* Details Recommendations block */
.recommendations-detail {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.rec-account-card {
    background: rgba(255, 255, 255, 0.015);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    padding: 1.25rem;
}

.rec-account-title {
    font-family: var(--font-heading);
    font-size: 0.95rem;
    font-weight: 700;
    margin-bottom: 0.75rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.rec-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.rec-item {
    display: grid;
    grid-template-columns: 1.8fr 1fr 1.2fr;
    padding: 0.6rem 0.85rem;
    background: var(--bg-input);
    border-radius: 8px;
    border: 1px solid var(--border-color);
    align-items: center;
    font-size: 0.8rem;
}

.rec-asset-name { font-weight: 600; }
.rec-asset-class { font-size: 0.75rem; color: var(--text-secondary); }
.rec-asset-action { text-align: right; font-weight: 700; }

.rec-asset-action.buy { color: var(--accent-emerald); }
.rec-asset-action.sell { color: var(--accent-rose); }
.rec-asset-action.keep { color: var(--text-muted); }

/* Warning box */
.warning-box {
    background: rgba(245, 158, 11, 0.08);
    border: 1px solid rgba(245, 158, 11, 0.2);
    border-radius: 10px;
    padding: 0.85rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    color: var(--accent-amber);
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 1.5rem;
}

/* Utilities */
.reset-btn {
    background: transparent;
    border: 1px dashed var(--text-muted);
    color: var(--text-secondary);
    padding: 0.5rem 0.85rem;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    transition: var(--transition-smooth);
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.8rem;
}

.reset-btn:hover {
    color: var(--accent-rose);
    border-color: var(--accent-rose);
    background: rgba(244, 63, 94, 0.05);
}

.mt-1 { margin-top: 1rem; }
.mb-05 { margin-bottom: 0.5rem; }

/* Responsive Styles */
@media (max-width: 1024px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
    
    .result-col {
        position: relative;
        top: 0;
        max-height: none;
        overflow-y: visible;
        padding-right: 0;
    }
}

@media (max-width: 768px) {
    .stats-bar {
        grid-template-columns: 1fr;
    }
    
    .target-grid {
        grid-template-columns: 1fr;
    }
    
    .target-visualization {
        border-left: none;
        padding-left: 0;
        border-top: 1px solid var(--border-color);
        padding-top: 1.5rem;
    }
}
