/* Stock Tracker - Shared Styles */

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #f3f4f6;
    color: #1f2937;
    line-height: 1.5;
}

/* Login */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #059669 0%, #047857 100%);
}

.login-box {
    background: white;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    width: 100%;
    max-width: 360px;
    text-align: center;
}

.login-box h1 {
    color: #059669;
    margin-bottom: 0.25rem;
}

.login-box p {
    color: #6b7280;
    margin-bottom: 1.5rem;
}

.login-box .register-link {
    margin-top: 1rem;
    font-size: 0.875rem;
    color: #6b7280;
}

.login-box .register-link a {
    color: #059669;
    text-decoration: none;
}

.login-box .register-link a:hover {
    text-decoration: underline;
}

/* Header */
.header {
    background: white;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 1rem;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.logo {
    font-size: 1.25rem;
    font-weight: 700;
    color: #059669;
}

.nav-links {
    display: flex;
    gap: 0.5rem;
}

.nav-links a {
    color: #4b5563;
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    transition: all 0.2s;
}

.nav-links a:hover {
    background: #f3f4f6;
}

.nav-links a.active {
    background: #059669;
    color: white;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-size: 0.875rem;
    color: #6b7280;
}

/* Main Content */
.main-container {
    min-height: 100vh;
}

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

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

.page-header h2 {
    color: #1f2937;
    font-size: 1.5rem;
}

/* Cards */
.card {
    background: white;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.card h3 {
    margin-bottom: 1rem;
    color: #374151;
}

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

/* Portfolio Cards Grid */
.portfolio-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}

.portfolio-card {
    background: white;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    padding: 1.5rem;
    cursor: pointer;
    transition: all 0.2s;
    border: 2px solid transparent;
}

.portfolio-card:hover {
    border-color: #059669;
    transform: translateY(-2px);
}

.portfolio-card h4 {
    color: #1f2937;
    margin-bottom: 0.5rem;
}

.portfolio-card .description {
    color: #6b7280;
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

.portfolio-card .stats {
    display: flex;
    justify-content: space-between;
    font-size: 0.875rem;
}

.portfolio-card .holdings-count {
    color: #6b7280;
}

/* Two Column Layout */
.two-column {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

@media (max-width: 992px) {
    .two-column {
        grid-template-columns: 1fr;
    }
}

/* Forms */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.25rem;
    font-weight: 500;
    color: #374151;
    font-size: 0.875rem;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    font-size: 1rem;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #059669;
    box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.1);
}

.form-group small {
    color: #6b7280;
    font-size: 0.75rem;
}

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

@media (max-width: 640px) {
    .form-row {
        grid-template-columns: 1fr;
    }
}

.form-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
}

/* Buttons */
.btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 4px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    display: inline-block;
}

.btn-primary {
    background: #059669;
    color: white;
}

.btn-primary:hover {
    background: #047857;
}

.btn-secondary {
    background: #6b7280;
    color: white;
}

.btn-secondary:hover {
    background: #4b5563;
}

.btn-success {
    background: #10b981;
    color: white;
}

.btn-success:hover {
    background: #059669;
}

.btn-danger {
    background: #ef4444;
    color: white;
}

.btn-danger:hover {
    background: #dc2626;
}

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

.btn-outline {
    background: transparent;
    border: 1px solid #d1d5db;
    color: #374151;
}

.btn-outline:hover {
    background: #f3f4f6;
}

/* Tables */
.table-container {
    overflow-x: auto;
}

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

th, td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid #e5e7eb;
}

th {
    background: #f9fafb;
    font-weight: 600;
    color: #374151;
    font-size: 0.875rem;
}

tbody tr:hover {
    background: #f9fafb;
}

.no-data {
    text-align: center;
    color: #9ca3af;
    padding: 2rem !important;
}

.table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    color: #6b7280;
    font-size: 0.875rem;
}

/* Financial Values - Positive/Negative */
.positive {
    color: #059669;
}

.negative {
    color: #dc2626;
}

.gain {
    color: #059669;
    font-weight: 600;
}

.loss {
    color: #dc2626;
    font-weight: 600;
}

td.number, th.number {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

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

.stat-card {
    background: white;
    padding: 1rem;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    text-align: center;
}

.stat-label {
    font-size: 0.75rem;
    color: #6b7280;
    text-transform: uppercase;
    margin-bottom: 0.25rem;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: #1f2937;
}

.stat-value.positive {
    color: #059669;
}

.stat-value.negative {
    color: #dc2626;
}

.stat-note {
    font-size: 0.75rem;
    color: #6b7280;
    margin-top: 0.25rem;
}

/* Chart Container */
.chart-container {
    background: white;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    padding: 1rem;
    margin-bottom: 1.5rem;
}

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

.chart-header h3 {
    margin: 0;
}

.chart-controls {
    display: flex;
    gap: 0.5rem;
}

.chart-controls button {
    padding: 0.25rem 0.75rem;
    border: 1px solid #d1d5db;
    background: white;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.75rem;
}

.chart-controls button.active {
    background: #059669;
    border-color: #059669;
    color: white;
}

.chart-controls .control-label {
    font-size: 0.75rem;
    color: #6b7280;
    margin-right: 0.25rem;
}

.chart-controls .control-divider {
    color: #d1d5db;
    margin: 0 0.25rem;
}

.chart-controls .benchmark-btn {
    background: #f9fafb;
}

.chart-controls .benchmark-btn.active {
    background: #6366f1;
    border-color: #6366f1;
    color: white;
}

#price-chart {
    width: 100%;
    height: 400px;
}

/* Symbol Search */
.symbol-search {
    position: relative;
}

.symbol-search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 10;
    display: none;
}

.symbol-search-results.active {
    display: block;
}

.symbol-search-item {
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    border-bottom: 1px solid #e5e7eb;
}

.symbol-search-item:hover {
    background: #f3f4f6;
}

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

.symbol-search-item .symbol {
    font-weight: 600;
    color: #1f2937;
}

.symbol-search-item .name {
    font-size: 0.75rem;
    color: #6b7280;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    align-items: center;
    justify-content: center;
    z-index: 200;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: white;
    padding: 1.5rem;
    border-radius: 8px;
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-content h3 {
    margin-bottom: 1rem;
}

.modal-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
    margin-top: 1rem;
}

/* Transaction Type Buttons */
.transaction-type-buttons {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.transaction-type-btn {
    flex: 1;
    padding: 0.75rem;
    border: 2px solid #d1d5db;
    background: white;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s;
}

.transaction-type-btn:hover {
    border-color: #059669;
}

.transaction-type-btn.buy.selected {
    background: #059669;
    border-color: #059669;
    color: white;
}

.transaction-type-btn.sell.selected {
    background: #dc2626;
    border-color: #dc2626;
    color: white;
}

.transaction-type-btn.dividend.selected {
    background: #3b82f6;
    border-color: #3b82f6;
    color: white;
}

/* Messages */
.error-msg {
    color: #dc2626;
    font-size: 0.875rem;
    margin-top: 0.5rem;
}

.success-msg {
    color: #059669;
    font-size: 0.875rem;
    margin-top: 0.5rem;
}

.alert {
    padding: 1rem;
    border-radius: 4px;
    margin-bottom: 1rem;
}

.alert-error {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #dc2626;
}

.alert-success {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    color: #059669;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 0.25rem;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid #e5e7eb;
}

.tab-btn {
    padding: 0.75rem 1.5rem;
    border: none;
    background: transparent;
    cursor: pointer;
    font-weight: 500;
    color: #6b7280;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: all 0.2s;
}

.tab-btn:hover {
    color: #059669;
}

.tab-btn.active {
    color: #059669;
    border-bottom-color: #059669;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Filters */
.filter-card {
    padding: 1rem 1.5rem;
}

.filter-row {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    align-items: flex-end;
}

.filter-row .form-group {
    margin-bottom: 0;
    min-width: 150px;
}

.filter-buttons {
    display: flex;
    gap: 0.5rem;
}

/* Pagination */
.pagination {
    display: flex;
    gap: 0.25rem;
    justify-content: center;
    margin-top: 1rem;
    flex-wrap: wrap;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: #6b7280;
}

.empty-state h3 {
    color: #374151;
    margin-bottom: 0.5rem;
}

.empty-state p {
    margin-bottom: 1rem;
}

/* Loading */
.loading {
    text-align: center;
    padding: 2rem;
    color: #6b7280;
}

.loading::after {
    content: '';
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid #d1d5db;
    border-top-color: #059669;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-left: 0.5rem;
    vertical-align: middle;
}

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

/* Badge */
.badge {
    display: inline-block;
    padding: 0.125rem 0.5rem;
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: 9999px;
}

.badge-admin {
    background: #fef3c7;
    color: #d97706;
}

.badge-user {
    background: #dbeafe;
    color: #2563eb;
}

.badge-active {
    background: #d1fae5;
    color: #059669;
}

.badge-inactive {
    background: #fee2e2;
    color: #dc2626;
}

/* Responsive */
@media (max-width: 768px) {
    .header-content {
        flex-wrap: wrap;
        height: auto;
        padding: 0.75rem 1rem;
    }

    .nav-links {
        order: 3;
        width: 100%;
        justify-content: center;
        flex-wrap: wrap;
    }

    .nav-links a {
        padding: 0.5rem 0.75rem;
        font-size: 0.875rem;
    }

    .filter-row {
        flex-direction: column;
    }

    .filter-row .form-group {
        width: 100%;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    #price-chart {
        height: 300px;
    }
}
