/* =========================================
   Stock Portfolio Manager Specific Styles
   ========================================= */

   .portfolio-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    text-align: left !important;
}

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

.icon-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-color);
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 1.1rem;
}

.icon-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.portfolio-layout {
    display: grid;
    grid-template-columns: 1fr 350px;
    gap: 2rem;
    margin-bottom: 4rem;
}

@media (max-width: 900px) {
    .portfolio-layout {
        grid-template-columns: 1fr;
    }
}

.portfolio-sidebar {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.chart-panel {
    padding: 1.5rem;
}

.form-panel {
    padding: 1.75rem;
    background: linear-gradient(145deg, rgba(40, 20, 60, 0.8), rgba(20, 10, 30, 0.95));
    border: 1px solid rgba(168, 85, 247, 0.5);
    box-shadow: 0 8px 32px rgba(168, 85, 247, 0.2);
    border-radius: 12px;
}

.form-panel .input-group label {
    font-size: 1.1rem;
    color: #fff;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.form-panel input {
    font-size: 1.25rem;
    padding: 0.8rem;
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(168, 85, 247, 0.6);
    color: #fff;
}

.form-panel input:focus {
    border-color: #a855f7;
    box-shadow: 0 0 0 3px rgba(168, 85, 247, 0.4);
}

.chart-panel h3 {
    margin-bottom: 1.5rem;
    font-size: 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--accent-color, #a855f7);
}

.form-panel h3 {
    margin-bottom: 0.75rem;
    font-size: 1.1rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--accent-color, #a855f7);
}

.full-width {
    width: 100%;
    margin-top: 1rem;
}

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

.summary-card {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    border-top: 2px solid rgba(168, 85, 247, 0.5); /* Lavish purple accent */
}

.summary-label {
    font-size: 0.9rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}

.summary-value {
    font-size: 1.4rem;
    font-weight: 700;
    font-family: 'JetBrains Mono', monospace;
}

/* Holdings Area */
.holdings-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 0.5rem;
}

.api-status {
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-weight: 500;
    padding: 0.4rem 0.8rem;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.05);
    transition: background 0.2s ease;
}

.api-status:hover {
    background: rgba(255, 255, 255, 0.15);
}

.api-status.offline { color: #facc15; }
.api-status.online { color: #4ade80; }

.holdings-list {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Stock Card */
.stock-card {
    position: relative;
    margin-left: 0;
    padding: 1.5rem;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    border-left: 4px solid #a855f7;
    background: rgba(20, 20, 30, 0.6);
}

.stock-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

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

.stock-title {
    display: flex;
    align-items: baseline;
    gap: 1rem;
}

.stock-ticker {
    font-size: 1.5rem;
    font-weight: 700;
    color: #fff;
    letter-spacing: 1px;
}

.stock-current-price {
    font-size: 1rem;
    color: #facc15;
    font-weight: 600;
    font-family: 'JetBrains Mono', monospace;
    cursor: pointer;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.05);
    transition: background 0.2s;
}
.stock-current-price:hover {
    background: rgba(255, 255, 255, 0.15);
}

.stock-actions button {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.5rem;
    transition: color 0.2s;
}

.stock-actions button:hover {
    color: #ef4444; /* red for delete */
}

.delete-stock-btn-inline:hover {
    background: rgba(239, 68, 68, 0.9) !important;
    color: #fff !important;
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

/* Aggregated Stats row */
.stock-agg-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 0.5rem;
    background: rgba(0, 0, 0, 0.2);
    padding: 0.75rem;
    border-radius: 8px;
    margin-bottom: 0.75rem;
}

.stat-item {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.stat-lbl {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
}

.stat-val {
    font-size: 1rem;
    font-weight: 600;
    font-family: 'JetBrains Mono', monospace;
}

/* Profit Colors */
.profit-pos { color: #4ade80; }
.profit-neg { color: #f87171; }
.profit-neu { color: var(--text-muted); }

/* Lots Table */
.lots-container {
    margin-top: 1rem;
}

.lots-title {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.lots-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
    font-family: 'JetBrains Mono', monospace;
}

.lots-table th {
    text-align: right;
    padding: 0.5rem;
    color: var(--text-muted);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    font-weight: 500;
    font-family: 'Outfit', sans-serif;
}
.lots-table th:first-child { text-align: left; }

.lots-table td {
    text-align: right;
    padding: 0.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}
.lots-table td:first-child { text-align: left; }

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

.lots-table tr:hover td {
    background: rgba(255, 255, 255, 0.03);
}

.delete-lot-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.8rem;
}
.delete-lot-btn:hover { color: #ef4444; }

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.modal-overlay:not(.hidden) {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    width: 90%;
    max-width: 450px;
    padding: 2rem;
    transform: translateY(20px);
    transition: transform 0.3s ease;
}

.modal-overlay:not(.hidden) .modal-content {
    transform: translateY(0);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.modal-header h2 {
    font-size: 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.modal-footer {
    margin-top: 1.5rem;
    display: flex;
    justify-content: flex-end;
}

/* Sorting Controls */
.sort-select {
    background: rgba(20, 20, 30, 0.8);
    color: var(--text-color);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-family: 'Outfit', sans-serif;
    font-size: 0.9rem;
    cursor: pointer;
    outline: none;
    transition: all 0.2s;
}

.sort-select:hover, .sort-select:focus {
    border-color: rgba(168, 85, 247, 0.5);
    background: rgba(30, 30, 40, 0.9);
}

.sort-select option {
    background: #1e1e2d;
    color: #fff;
}

/* Inline Add Purchase Form */
.inline-add-lot {
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.inline-add-lot h4 {
    font-size: 0.9rem;
    margin-bottom: 0.75rem;
    color: var(--text-muted);
}

.inline-form-row {
    display: flex;
    gap: 0.75rem;
    align-items: flex-end;
}

.inline-form-row .input-group {
    flex: 1;
    margin-bottom: 0;
}

.inline-form-row .input-group label {
    font-size: 0.75rem;
    margin-bottom: 0.25rem;
}

.inline-form-row .btn {
    padding: 0.6rem 1rem;
    height: 42px;
}

@media (max-width: 600px) {
    .inline-form-row {
        flex-direction: column;
        align-items: stretch;
    }
    .inline-form-row .btn {
        margin-top: 0.5rem;
    }
}

/* Hidden Form & Toggle */
.hidden-form {
    display: none !important;
}

.add-lot-toggle-btn {
    background: rgba(34, 197, 94, 0.15); /* subtle green */
    color: #4ade80; /* bright green text */
    border: 1px solid rgba(34, 197, 94, 0.3);
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    margin-top: 1rem;
    min-width: 100px;
    width: fit-content;
}
.add-lot-toggle-btn:hover {
    background: rgba(34, 197, 94, 0.25);
    border-color: rgba(34, 197, 94, 0.5);
    transform: translateY(-1px);
}

.cancel-btn {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-muted);
    padding: 0.6rem 1rem;
    height: 42px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}
.cancel-btn:hover {
    background: rgba(239, 68, 68, 0.15);
    border-color: rgba(239, 68, 68, 0.3);
    color: #ef4444;
}

/* Collapse Toggle Styles */
.stock-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    cursor: pointer;
    user-select: none;
    transition: background 0.2s;
    padding: 0.5rem;
    margin: -0.5rem -0.5rem 0.5rem -0.5rem;
    border-radius: 8px;
}

.stock-header:hover {
    background: rgba(255, 255, 255, 0.03);
}

.stock-summary-inline {
    display: flex;
    gap: 1.5rem;
    align-items: center;
    font-size: 0.9rem;
    color: var(--text-color);
    font-family: 'JetBrains Mono', monospace;
    flex: 1;
    justify-content: center;
}

.stock-summary-inline .lbl {
    color: var(--text-muted);
    text-transform: uppercase;
    font-size: 0.75rem;
    font-family: 'Outfit', sans-serif;
    margin-right: 0.4rem;
}

.stock-summary-inline .divider {
    color: rgba(255, 255, 255, 0.1);
}

.toggle-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.5rem;
    transition: color 0.2s;
}

.toggle-icon {
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.stock-card.collapsed {
    padding: 0.75rem 1.5rem;
}

.stock-card.collapsed .stock-header {
    margin-bottom: 0;
}

.stock-card.collapsed .stock-body {
    display: none;
}

.stock-card.collapsed .toggle-icon {
    transform: rotate(180deg);
}

@media (max-width: 800px) {
    .stock-summary-inline {
        display: none;
    }
}
@keyframes blink-red-panel {
    0% { color: #ef4444; background: rgba(239, 68, 68, 0.15); box-shadow: 0 0 8px rgba(239, 68, 68, 0.4); }
    50% { color: rgba(239, 68, 68, 0.5); background: rgba(239, 68, 68, 0.05); box-shadow: none; }
    100% { color: #ef4444; background: rgba(239, 68, 68, 0.15); box-shadow: 0 0 8px rgba(239, 68, 68, 0.4); }
}

.blink-warning-panel {
    animation: blink-red-panel 1.5s infinite;
    border: 1px solid rgba(239, 68, 68, 0.5) !important;
}

@keyframes blink-red-text {
    0% { color: #ef4444; opacity: 1; }
    50% { color: #ef4444; opacity: 0.4; }
    100% { color: #ef4444; opacity: 1; }
}

.blink-warning-text {
    animation: blink-red-text 1.5s infinite;
    color: #ef4444;
}
