/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: 10px 20px;
    border: 1px solid transparent;
    border-radius: var(--radius);
    font-family: var(--font-sans);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    text-decoration: none;
    line-height: 1.4;
    white-space: nowrap;
}

.btn:focus-visible {
    outline: 2px solid var(--green);
    outline-offset: 2px;
}

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

.btn-primary:hover {
    background: var(--green-dark);
    border-color: var(--green-dark);
    color: var(--white);
}

.btn-secondary {
    background: var(--white);
    color: var(--ink);
    border-color: var(--line);
}

.btn-secondary:hover {
    background: var(--cream);
    border-color: var(--muted);
}

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

.btn-danger:hover {
    background: #c82333;
    border-color: #c82333;
    color: var(--white);
}

.btn-sm {
    padding: 6px 14px;
    font-size: 0.85rem;
}

.btn-lg {
    padding: 14px 28px;
    font-size: 1.1rem;
}

.btn-block {
    width: 100%;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Cards */
.card {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.card-header {
    padding: var(--space-md) var(--space-lg);
    border-bottom: 1px solid var(--line);
    font-weight: 600;
    font-size: 1.05rem;
}

.card-body {
    padding: var(--space-lg);
}

/* Stock card */
.stock-card {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: var(--space-lg);
    transition: all 0.2s ease;
    display: block;
    text-decoration: none;
    color: var(--ink);
    border: 1px solid transparent;
}

.stock-card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
    border-color: var(--line);
    color: var(--ink);
}

.stock-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: var(--space-md);
}

.stock-card-ticker {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--green);
}

.stock-card-exchange {
    font-size: 0.75rem;
    color: var(--muted);
    background: var(--cream);
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    font-weight: 500;
}

.stock-card-name {
    font-size: 0.95rem;
    color: var(--ink-light);
    margin-bottom: var(--space-md);
    line-height: 1.4;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.stock-card-price {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
}

.stock-card-price-value {
    font-size: 1.25rem;
    font-weight: 700;
}

/* Add stock card */
.add-stock-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-md);
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: var(--space-sm) var(--space-md);
    margin-bottom: var(--space-sm);
}

.add-stock-card-info {
    display: flex;
    align-items: baseline;
    gap: var(--space-sm);
    flex-wrap: wrap;
    min-width: 0;
}

.add-stock-card-ticker {
    font-weight: 700;
    color: var(--green);
}

.add-stock-card-name {
    color: var(--ink-light);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.add-stock-card-exchange {
    font-size: 0.75rem;
    color: var(--muted);
    background: var(--cream);
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    font-weight: 500;
    white-space: nowrap;
}

.add-stock-btn:disabled {
    opacity: 0.6;
    cursor: default;
}

/* Form elements */
.form-group {
    margin-bottom: var(--space-md);
}

.form-group label {
    display: block;
    font-weight: 500;
    margin-bottom: var(--space-xs);
    font-size: 0.95rem;
    color: var(--ink);
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    font-family: var(--font-sans);
    font-size: 1rem;
    color: var(--ink);
    background: var(--white);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    line-height: 1.5;
}

.form-control:focus {
    outline: none;
    border-color: var(--green);
    box-shadow: 0 0 0 3px rgba(23, 107, 87, 0.12);
}

.form-control::placeholder {
    color: var(--muted);
}

.form-error {
    color: var(--red);
    font-size: 0.85rem;
    margin-top: var(--space-xs);
}

/* Alerts */
.alert {
    padding: var(--space-md);
    border-radius: var(--radius);
    margin-bottom: var(--space-lg);
    font-size: 0.95rem;
    border: 1px solid transparent;
}

.alert-success {
    background: var(--mint);
    color: var(--green-dark);
    border-color: var(--green-light);
}

.alert-error {
    background: var(--red-light);
    color: var(--red);
    border-color: var(--red);
}

/* Badges */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1.6;
    white-space: nowrap;
}

.badge-green {
    background: var(--mint);
    color: var(--green);
}

.badge-red {
    background: var(--coral-light);
    color: var(--coral);
}

.badge-yellow {
    background: var(--yellow-light);
    color: #866300;
}

.badge-blue {
    background: var(--blue-light);
    color: var(--blue);
}

.badge-gray {
    background: var(--cream);
    color: var(--muted);
}

/* Score badge (larger) */
.score-badge {
    display: inline-block;
    padding: 8px 16px;
    border-radius: var(--radius);
    font-size: 1.25rem;
    font-weight: 700;
    line-height: 1.4;
}

/* Tables */
.table {
    width: 100%;
    border-collapse: collapse;
}

.table th {
    background: var(--cream);
    font-weight: 600;
    text-align: left;
    padding: var(--space-sm) var(--space-md);
    font-size: 0.9rem;
    color: var(--ink-light);
    border-bottom: 2px solid var(--line);
}

.table td {
    padding: var(--space-sm) var(--space-md);
    border-bottom: 1px solid var(--line);
    font-size: 0.95rem;
}

.table-striped tbody tr:nth-child(even) {
    background: rgba(240, 246, 241, 0.5);
}

.table tbody tr:hover {
    background: var(--mint);
}

.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* KPI Grid */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--space-md);
}

.kpi-item {
    text-align: center;
    padding: var(--space-md);
    background: var(--white);
    border-radius: var(--radius);
    border: 1px solid var(--line);
}

.kpi-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--ink);
    line-height: 1.3;
}

.kpi-label {
    font-size: 0.85rem;
    color: var(--muted);
    margin-top: var(--space-xs);
}

@media (max-width: 768px) {
    .kpi-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 480px) {
    .kpi-grid {
        grid-template-columns: 1fr;
    }
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: var(--space-3xl) var(--space-lg);
    color: var(--muted);
}

.empty-state-icon {
    font-size: 3rem;
    margin-bottom: var(--space-md);
    opacity: 0.5;
}

.empty-state-message {
    font-size: 1.1rem;
    margin-bottom: var(--space-lg);
}

.empty-state .btn {
    margin-top: var(--space-md);
}

/* Search box */
.search-box {
    position: relative;
    max-width: 600px;
    margin: 0 auto;
}

.search-box .search-icon {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--muted);
    font-size: 1.1rem;
    pointer-events: none;
}

.search-box .search-input {
    width: 100%;
    padding: 14px 20px 14px 48px;
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    font-family: var(--font-sans);
    font-size: 1.1rem;
    color: var(--ink);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.search-box .search-input:focus {
    outline: none;
    border-color: var(--green);
    box-shadow: var(--shadow-lg), 0 0 0 3px rgba(23, 107, 87, 0.12);
}

.search-box .search-input::placeholder {
    color: var(--muted);
}

/* Score meter */
.score-meter {
    position: relative;
    height: 8px;
    border-radius: 4px;
    background: linear-gradient(to right, var(--red), var(--yellow), var(--green-light));
    margin: var(--space-md) 0;
}

.score-meter-marker {
    position: absolute;
    top: -6px;
    width: 20px;
    height: 20px;
    background: var(--white);
    border: 3px solid var(--ink);
    border-radius: 50%;
    transform: translateX(-50%);
    box-shadow: var(--shadow-sm);
}

/* Price change */
.price-change {
    font-weight: 600;
    font-size: 0.95rem;
}

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

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

/* Loading spinner */
.loading-spinner {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: var(--space-xl);
}

.loading-spinner::after {
    content: '';
    width: 32px;
    height: 32px;
    border: 3px solid var(--line);
    border-top-color: var(--green);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

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

/* Dropdown */
.dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--line);
    min-width: 180px;
    z-index: 50;
    display: none;
}

.dropdown-menu.open {
    display: block;
}

.dropdown-menu a {
    display: block;
    padding: var(--space-sm) var(--space-md);
    color: var(--ink);
    font-size: 0.95rem;
}

.dropdown-menu a:hover {
    background: var(--cream);
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

.modal-overlay.open {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    padding: var(--space-xl);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-lg);
}

.modal-header h3 {
    font-size: 1.25rem;
    font-weight: 700;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--muted);
    padding: var(--space-xs);
    line-height: 1;
}

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

/* Disclaimer */
.disclaimer {
    font-size: 0.8rem;
    color: var(--muted);
    font-style: italic;
    margin-top: var(--space-xl);
    padding: var(--space-md);
    border-top: 1px solid var(--line);
    line-height: 1.5;
}
