/**
 * Networth2 Main Stylesheet — Dark Theme
 */

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

:root {
    --primary-color: #111111;
    --secondary-color: #3498db;
    --success-color: #27ae60;
    --danger-color: #e74c3c;
    --warning-color: #f39c12;
    --bg-page: #0d0d0d;
    --bg-card: #1a1a1a;
    --bg-elevated: #222222;
    --bg-input: #111111;
    --text-primary: #e0e0e0;
    --text-secondary: #888888;
    --border-color: #2e2e2e;
    --card-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
    /* Legacy aliases kept for any remaining references */
    --light-bg: #222222;
    --dark-text: #e0e0e0;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg-page);
    color: var(--text-primary);
    line-height: 1.6;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Navigation */
.navbar {
    background-color: var(--primary-color);
    color: white;
    padding: 1rem 0;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--card-shadow);
    border-bottom: 1px solid var(--border-color);
}

.nav-brand {
    font-size: 1.5rem;
    font-weight: bold;
    display: inline-block;
    margin-bottom: 1rem;
}

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

/* Hamburger toggle — visible only at the mobile breakpoint (see the
   max-width: 768px block below). Hidden on desktop so the full menu
   renders inline as before. */
.nav-toggle {
    display: none;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    font-size: 1.3rem;
    line-height: 1;
    padding: 0.35rem 0.65rem;
    border-radius: 4px;
    cursor: pointer;
}
.nav-toggle:hover { background: rgba(255, 255, 255, 0.08); }

.nav-menu a {
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    transition: color 0.3s;
}

.nav-menu a:hover,
.nav-menu a.active {
    color: white;
    border-bottom: 2px solid var(--secondary-color);
}

/* Submenu */
.nav-item-with-submenu {
    position: relative;
}

.nav-submenu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    background: #111;
    list-style: none;
    flex-direction: column;
    gap: 0;
    padding: 0.5rem 0;
    margin: 0;
    border-radius: 4px;
    min-width: 180px;
    z-index: 1000;
    border: 1px solid var(--border-color);
}

.nav-item-with-submenu:hover .nav-submenu {
    display: flex;
}

.nav-submenu li {
    margin: 0;
}

.nav-submenu a {
    display: block;
    padding: 0.75rem 1rem;
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    transition: color 0.3s, background 0.3s;
    border-bottom: none;
}

.nav-submenu a:hover {
    color: white;
    background: rgba(255, 255, 255, 0.08);
    border-bottom: none;
}

/* Warnings bell — sits at the far right of the nav menu, hidden until
   the warnings poll reports a non-empty list. */
.nav-warnings-item { margin-left: auto; }
.nav-warnings-bell {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    background: rgba(212, 152, 80, 0.15);
    border: 1px solid #d49850;
    color: #d49850 !important;
    text-decoration: none;
    font-size: 1rem;
    line-height: 1;
}
.nav-warnings-bell:hover {
    background: rgba(212, 152, 80, 0.25);
    border-bottom: 1px solid #d49850 !important;
}
.nav-warnings-icon { font-size: 1.05rem; }
.nav-warnings-badge {
    background: #d49850;
    color: #1a1a1a;
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 1px 6px;
    min-width: 18px;
    text-align: center;
}

/* Main Content */
.dashboard {
    padding: 2rem 0;
}

/* Two summary cards side-by-side */
.summary-cards-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 2rem;
}
.summary-cards-grid .summary-card {
    margin-bottom: 0;
}
@media (max-width: 600px) {
    .summary-cards-grid { grid-template-columns: 1fr; }
}

/* Cards and Sections */
.summary-card {
    background: var(--bg-card);
    border-radius: 8px;
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: var(--card-shadow);
    text-align: center;
}

.summary-card h1 {
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.net-worth-display {
    margin: 2rem 0;
}

.net-worth-display .amount {
    font-size: 3rem;
    font-weight: bold;
    color: var(--secondary-color);
    margin-bottom: 0.5rem;
}

.amount-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.icon-link {
    text-decoration: none;
    font-size: 0.85em;
    opacity: 0.6;
    vertical-align: middle;
}

.icon-link:hover {
    opacity: 1;
}

.net-worth-display .change {
    font-size: 1.5rem;
    margin-top: 0.5rem;
}

.change.positive {
    color: var(--success-color);
}

.change.negative {
    color: var(--danger-color);
}

/* Asset Grid */
.assets-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.asset-card {
    max-width: 380px;
    width: 100%;
    background: var(--bg-card);
    border-radius: 8px;
    padding: 0.75rem;
    box-shadow: var(--card-shadow);
    text-align: center;
    transition: transform 0.3s;
}

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

/* Wide variant — spans 3 grid tracks for side-by-side sub-panels. */
.asset-card-wide {
    grid-column: span 3;
    max-width: none;
    text-align: left;
}

/* Graceful collapse at narrower breakpoints so the card never requests
   more tracks than the grid actually has. Thresholds line up with the
   190px auto-fill tracks + 0.75rem gap. */
@media (max-width: 593px) {
    .asset-card-wide {
        grid-column: span 2;
    }
}
@media (max-width: 399px) {
    .asset-card-wide {
        grid-column: auto;
    }
}

/* Drag-to-reorder affordances */
.asset-card[draggable="true"] { cursor: grab; }
.asset-card[draggable="true"]:active { cursor: grabbing; }
.asset-card.dragging { opacity: 0.4; }
.asset-card.drag-over { outline: 2px dashed #007bff; outline-offset: -2px; }

.asset-card h3 {
    margin-bottom: 0.5rem;
    font-size: 0.95rem;
    color: var(--text-primary);
}

.asset-value {
    font-size: 1.3rem;
    font-weight: bold;
    color: var(--secondary-color);
    margin-bottom: 0.25rem;
}

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

.asset-breakdown {
    display: flex;
    flex-direction: column;
    gap: 0;
    align-items: flex-start;
}

.breakdown-item {
    display: flex;
    justify-content: space-between;
    width: 100%;
    padding: 0.05rem 0;
}

.breakdown-item:last-child {
    border-bottom: none;
}

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

.breakdown-item .asset-value {
    font-size: 0.85rem;
    margin-bottom: 0;
}

.breakdown-total {
    border-top: 2px solid #3498db !important;
    padding-top: 0.2rem !important;
    margin-top: 0.15rem !important;
    border-bottom: none !important;
}

.breakdown-total .breakdown-label {
    font-weight: bold;
    color: var(--text-primary);
}

.breakdown-total .asset-value {
    font-weight: bold;
    font-size: 0.9rem;
}

/* Buttons */
.quick-actions {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.btn {
    padding: 0.75rem 1.5rem;
    border-radius: 4px;
    text-decoration: none;
    cursor: pointer;
    border: none;
    font-size: 1rem;
    transition: background-color 0.3s, transform 0.2s;
}

.btn:active {
    transform: scale(0.98);
}

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

.btn-primary:hover {
    background-color: #2980b9;
}

.btn-secondary {
    background-color: #333;
    color: var(--text-primary);
}

.btn-secondary:hover {
    background-color: #444;
}

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

.btn-danger:hover {
    background-color: #c0392b;
}

.btn-small {
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
    width: 100%;
}

/* Footer */
.page-footer {
    text-align: center;
    padding: 1rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
    border-top: 1px solid var(--border-color);
    margin-top: 2rem;
}

/* Account Groups */
.account-group {
    margin-bottom: 2.5rem;
}

.account-group-header {
    font-size: 1.3rem;
    color: var(--text-primary);
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--secondary-color);
}

.holdings-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1rem;
}

/* Item Cards */
.item-card {
    background: var(--bg-card);
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: var(--card-shadow);
    border-left: 4px solid var(--secondary-color);
    transition: transform 0.2s, box-shadow 0.2s;
}

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

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

.item-header h4 {
    margin: 0;
    color: var(--text-primary);
    font-size: 1.2rem;
}

.item-badge {
    background-color: var(--secondary-color);
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
}

.item-details {
    margin-bottom: 1rem;
}

.item-details p {
    margin: 0.5rem 0;
    font-size: 0.95rem;
    color: var(--text-secondary);
}

.item-details strong {
    color: var(--text-primary);
}

.qty-input-field {
    width: 100px;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 1rem;
    font-family: 'Courier New', monospace;
    background: var(--bg-input);
    color: var(--text-primary);
}

.qty-input-field:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.3);
}

/* Tables */
table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-card);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: var(--card-shadow);
}

thead {
    background-color: #1e3050;
    color: white;
}

th, td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

tbody tr:hover {
    background-color: var(--bg-elevated);
}

tbody tr:last-child td {
    border-bottom: none;
}

/* Inputs (global) */
input, select, textarea {
    background: var(--bg-input);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

input::placeholder {
    color: var(--text-secondary);
}

/* Responsive */
@media (max-width: 768px) {
    /* Hamburger drawer — full menu collapses behind a toggle button so the
       navbar stays one row tall until tapped open. */
    .navbar { padding: 0.5rem 0; }
    /* index.html drops the toggle+menu directly inside .navbar; the
       other pages wrap them in a .container. Make either the flex
       parent so the toggle anchors right and the menu wraps to a
       second row when .open. */
    .navbar,
    .navbar .container {
        display: flex;
        flex-wrap: wrap;
        justify-content: flex-end;
        align-items: center;
    }
    .nav-toggle {
        display: inline-flex;
        align-items: center;
    }
    .nav-menu {
        display: none;
        flex-direction: column;
        gap: 0;
        flex-basis: 100%;
        margin-top: 0.5rem;
    }
    .nav-menu.open { display: flex; }
    .nav-menu > li { border-top: 1px solid rgba(255, 255, 255, 0.08); }
    .nav-menu > li > a {
        display: block;
        padding: 0.75rem 0.5rem;
    }
    .nav-warnings-item { margin-left: 0; }

    /* Submenus expand inline (tap the parent label) instead of hover dropdown. */
    .nav-submenu {
        position: static;
        display: none;
        border: none;
        background: rgba(255, 255, 255, 0.04);
        padding: 0;
        min-width: 0;
        border-radius: 0;
    }
    .nav-item-with-submenu:hover .nav-submenu { display: none; }
    .nav-item-with-submenu.submenu-open .nav-submenu { display: flex; }
    .nav-submenu a { padding: 0.6rem 1.5rem; }

    .net-worth-display .amount {
        font-size: 2rem;
    }

    .quick-actions {
        flex-direction: column;
    }

    .btn {
        width: 100%;
        text-align: center;
    }

    th, td {
        padding: 0.75rem;
        font-size: 0.9rem;
    }
}
