/* Stock Portfolio Split - Dark Theme */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
    /* Modern Dark Theme */
    --bg-primary: #020617;
    --bg-secondary: #0f172a;
    --bg-tertiary: #1e293b;
    --bg-card: #1c2128;
    --surface: #0f172a;
    --surface-highlight: #1e293b;
    
    /* Colors */
    --primary: #10b981;
    --primary-hover: #059669;
    --primary-glow: rgba(16, 185, 129, 0.15);
    --secondary: #3b82f6;
    --accent-purple: #a855f7;
    --accent-cyan: #06b6d4;
    --accent-yellow: #f59e0b;
    --accent-red: #ef4444;
    --danger: #ef4444;
    
    /* Text */
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    
    /* Border */
    --border: #334155;
    --border-light: #475569;
    
    /* Radius */
    --radius-lg: 1rem;
    --radius-md: 0.75rem;
    --radius-sm: 0.5rem;
    
    /* Font */
    --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
    
    /* Transition */
    --transition: 200ms cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: var(--font-sans);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1.5rem;
    padding-bottom: 5rem;
}

/* Header */
.header {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
    flex-wrap: wrap;
    gap: 1rem;
}

.header-content {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.logo {
    width: 3rem;
    height: 3rem;
    border-radius: var(--radius-md);
    background: linear-gradient(135deg, var(--primary), var(--primary-hover));
    display: grid;
    place-items: center;
    font-size: 1.5rem;
    box-shadow: 0 0 20px var(--primary-glow);
}

.header-text h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}

.header-text p {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

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

/* Buttons */
.btn {
    padding: 0.625rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface-highlight);
    color: var(--text-primary);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    white-space: nowrap;
}

.btn:hover {
    transform: translateY(-1px);
    border-color: var(--border-light);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-hover));
    border-color: var(--primary);
    color: white;
}

.btn-primary:hover {
    box-shadow: 0 4px 12px var(--primary-glow);
}

.btn-secondary {
    background: var(--surface-highlight);
    border-color: var(--border);
}

.btn-secondary:hover {
    background: var(--bg-tertiary);
}

.btn-danger {
    background: rgba(239, 68, 68, 0.1);
    border-color: var(--danger);
    color: var(--danger);
}

.btn-danger:hover {
    background: rgba(239, 68, 68, 0.2);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.2);
}

/* Form Card */
.form-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
}

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

#holding-form {
    display: grid;
    grid-template-columns: 1fr 1fr auto auto;
    gap: 1rem;
    align-items: end;
}

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

.form-group label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.form-group input {
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-size: 0.875rem;
    font-family: var(--font-sans);
    transition: var(--transition);
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.form-group input::placeholder {
    color: var(--text-muted);
}

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

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
    transition: var(--transition);
}

.stat-card:hover {
    transform: translateY(-2px);
    border-color: var(--border-light);
}

.stat-card.total {
    border-left: 3px solid var(--primary);
}

.stat-card.count {
    border-left: 3px solid var(--secondary);
}

.stat-card.avg {
    border-left: 3px solid var(--accent-purple);
}

.stat-icon {
    font-size: 2rem;
    width: 3rem;
    height: 3rem;
    display: grid;
    place-items: center;
    border-radius: var(--radius-md);
    background: var(--bg-tertiary);
}

.stat-content h3 {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
}

.stat-content p {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* Portfolio Section */
.portfolio-section {
    display: grid;
    grid-template-columns: 1.5fr 1fr;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.portfolio-table-container,
.chart-container {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
}

.portfolio-table-container h2,
.chart-container h2 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.table-wrapper {
    overflow-x: auto;
}

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

thead {
    background: var(--bg-tertiary);
    border-bottom: 2px solid var(--border);
}

th {
    padding: 0.75rem;
    text-align: left;
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

tbody tr {
    border-bottom: 1px solid var(--border);
    transition: var(--transition);
}

tbody tr:hover:not(.empty-state) {
    background: var(--bg-tertiary);
}

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

.ticker {
    font-weight: 600;
    color: var(--primary);
    text-transform: uppercase;
}

.amount {
    color: var(--text-primary);
    font-weight: 500;
}

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

.allocation-bar {
    flex: 1;
    height: 6px;
    background: var(--bg-tertiary);
    border-radius: 3px;
    overflow: hidden;
}

.allocation-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    border-radius: 3px;
    transition: width 0.3s ease;
}

.allocation-text {
    font-weight: 600;
    color: var(--text-primary);
    min-width: 3rem;
    text-align: right;
}

.actions {
    display: flex;
    gap: 0.5rem;
}

.btn-icon {
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    cursor: pointer;
    transition: var(--transition);
    font-size: 1rem;
}

.btn-icon:hover {
    transform: scale(1.1);
}

.btn-edit:hover {
    border-color: var(--secondary);
    color: var(--secondary);
}

.btn-delete:hover {
    border-color: var(--danger);
    color: var(--danger);
}

.empty-state td {
    padding: 3rem 1rem;
}

.empty-message {
    text-align: center;
    color: var(--text-muted);
}

.empty-icon {
    font-size: 3rem;
    display: block;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-message p {
    font-size: 1rem;
}

/* Chart */
.chart-wrapper {
    position: relative;
    min-height: 400px;
    max-height: 600px;
    height: 50vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

#allocation-chart {
    max-width: 100%;
    max-height: 100%;
}

.no-data-message {
    position: absolute;
    text-align: center;
    color: var(--text-muted);
}

.no-data-message span {
    font-size: 3rem;
    display: block;
    margin-bottom: 0.5rem;
    opacity: 0.5;
}

.no-data-message.hidden {
    display: none;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal.show {
    display: flex;
}

.modal-content {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow: auto;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5);
}

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

.modal-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
}

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

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

.modal-body {
    padding: 1.5rem;
}

.modal-body p {
    margin-bottom: 1rem;
    color: var(--text-secondary);
}

#import-textarea {
    width: 100%;
    height: 200px;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-family: 'Courier New', monospace;
    font-size: 0.875rem;
    resize: vertical;
}

#import-textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.file-upload {
    margin-top: 1rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}

#file-name {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.modal-footer {
    padding: 1.5rem;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
}

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

/* Responsive Design */
@media (max-width: 1024px) {
    .portfolio-section {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }

    .header {
        flex-direction: column;
        align-items: stretch;
    }

    .header-actions {
        justify-content: stretch;
    }

    .header-actions .btn {
        flex: 1;
    }

    #holding-form {
        grid-template-columns: 1fr;
    }

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

    .stat-card {
        padding: 1rem;
    }

    th, td {
        padding: 0.5rem;
        font-size: 0.8rem;
    }

    .allocation-bar {
        display: none;
    }
}

@media (max-width: 480px) {
    .logo {
        width: 2.5rem;
        height: 2.5rem;
        font-size: 1.25rem;
    }

    .header-text h1 {
        font-size: 1.25rem;
    }

    .header-text p {
        font-size: 0.75rem;
    }

    .btn {
        font-size: 0.75rem;
        padding: 0.5rem 0.75rem;
    }

    .table-wrapper {
        font-size: 0.75rem;
    }
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

tbody tr:not(.empty-state) {
    animation: fadeIn 0.3s ease;
}
