/* Material Design - Mobile First */

:root {
    --primary: #1a73e8;
    --primary-dark: #1557b0;
    --primary-light: #4285f4;
    --secondary: #34a853;
    --error: #ea4335;
    --warning: #fbbc04;
    --surface: #ffffff;
    --background: #f8f9fa;
    --on-surface: #202124;
    --on-surface-variant: #5f6368;
    --border: #dadce0;
    --shadow-sm: 0 1px 2px 0 rgba(60,64,67,0.3), 0 1px 3px 1px rgba(60,64,67,0.15);
    --shadow-md: 0 1px 3px 0 rgba(60,64,67,0.3), 0 4px 8px 3px rgba(60,64,67,0.15);
    --shadow-lg: 0 8px 12px 6px rgba(60,64,67,0.15), 0 4px 4px 0 rgba(60,64,67,0.3);
    --radius: 8px;
    --spacing-xs: 4px;
    --spacing-sm: 8px;
    --spacing-md: 16px;
    --spacing-lg: 24px;
    --spacing-xl: 32px;
}

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

body {
    font-family: 'Roboto', 'Google Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
    background: var(--background);
    color: var(--on-surface);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    font-family: 'Google Sans', 'Roboto', sans-serif;
    font-weight: 500;
    color: var(--on-surface);
}

h1 { font-size: 32px; line-height: 40px; }
h2 { font-size: 24px; line-height: 32px; }
h3 { font-size: 20px; line-height: 28px; }
h4 { font-size: 18px; line-height: 24px; }

/* Navigation Bar */
.navbar {
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.nav-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 var(--spacing-md);
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 64px;
}

.nav-left h2 {
    font-size: 20px;
    color: var(--on-surface);
    font-weight: 500;
}

.nav-right {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.nav-right span {
    display: none;
    color: var(--on-surface-variant);
    font-size: 14px;
    margin-right: var(--spacing-md);
}

.nav-link {
    padding: 8px 16px;
    color: var(--on-surface-variant);
    text-decoration: none;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    transition: background 0.2s, color 0.2s;
    position: relative;
    white-space: nowrap;
}

.nav-link:hover {
    background: rgba(26, 115, 232, 0.08);
    color: var(--primary);
}

.nav-link.active {
    background: rgba(26, 115, 232, 0.12);
    color: var(--primary);
}

/* Mobile Menu Toggle */
.menu-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
}

.menu-toggle span {
    display: block;
    width: 24px;
    height: 2px;
    background: var(--on-surface);
    margin: 5px 0;
    transition: 0.3s;
}

/* Alert Badge */
.alert-badge {
    display: none;
    position: absolute;
    top: 4px;
    right: 8px;
    background: var(--error);
    color: white;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
}

/* Main Content */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: var(--spacing-lg) var(--spacing-md);
}

.content-wrapper {
    max-width: 1400px;
    margin: 0 auto;
    padding: var(--spacing-lg) var(--spacing-md);
}

/* Cards */
.login-box, .dashboard-box, .alerts-container, .stocks-table-container {
    background: var(--surface);
    border-radius: var(--radius);
    padding: var(--spacing-lg);
    box-shadow: var(--shadow-sm);
    margin-bottom: var(--spacing-md);
}

/* Forms */
.form-group {
    margin-bottom: var(--spacing-lg);
}

label {
    display: block;
    color: var(--on-surface-variant);
    margin-bottom: var(--spacing-sm);
    font-size: 14px;
    font-weight: 500;
}

input[type="text"],
input[type="password"],
input[type="email"],
input[type="date"],
select {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 16px;
    font-family: inherit;
    transition: border-color 0.2s, box-shadow 0.2s;
    background: var(--surface);
}

input:focus,
select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(26, 115, 232, 0.1);
}

/* Buttons - Material Design */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 24px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.2s, box-shadow 0.2s, transform 0.1s;
    box-shadow: var(--shadow-sm);
    min-height: 40px;
}

.btn:hover {
    background: var(--primary-dark);
    box-shadow: var(--shadow-md);
}

.btn:active {
    transform: translateY(1px);
}

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

.btn-secondary {
    background: var(--surface);
    color: var(--primary);
    border: 1px solid var(--border);
    box-shadow: none;
}

.btn-secondary:hover {
    background: rgba(26, 115, 232, 0.08);
}

.btn-test {
    background: var(--secondary);
}

.btn-test:hover {
    background: #2d8e47;
}

.btn-quick {
    padding: 8px 16px;
    font-size: 13px;
    min-height: 36px;
}

.btn-recommend {
    background: var(--warning);
    color: var(--on-surface);
}

.btn-recommend:hover {
    background: #f9ab00;
}

/* Alerts */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: var(--spacing-md);
    font-size: 14px;
    border-left: 4px solid;
}

.alert-error {
    background: #fce8e6;
    border-color: var(--error);
    color: #c5221f;
}

.alert-success {
    background: #e6f4ea;
    border-color: var(--secondary);
    color: #137333;
}

/* Filter Section */
.filter-box {
    background: var(--surface);
    border-radius: var(--radius);
    padding: var(--spacing-lg);
    margin-bottom: var(--spacing-md);
    box-shadow: var(--shadow-sm);
}

.filter-box h2 {
    margin-bottom: var(--spacing-lg);
}

.quick-filters {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-lg);
}

.filter-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-md);
}

.form-actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-sm);
    margin-top: var(--spacing-md);
}

/* Timeframe Toggle */
.timeframe-toggle {
    display: inline-flex;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--surface);
}

.toggle-btn {
    padding: 8px 16px;
    background: transparent;
    color: var(--on-surface-variant);
    border: none;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: background 0.2s, color 0.2s;
}

.toggle-btn:not(:last-child) {
    border-right: 1px solid var(--border);
}

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

.toggle-btn:hover:not(.active) {
    background: rgba(26, 115, 232, 0.08);
}

/* Table Styles */
.stocks-table-container {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    margin-bottom: var(--spacing-md);
}

.table-scroll-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-height: none;
}

.stocks-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 14px;
    background: var(--surface);
    min-width: 1200px;
}

.stocks-table thead {
    background: #e8f0fe;
}

.stocks-table thead tr {
    box-shadow: 0 2px 4px rgba(60,64,67,0.15);
}

.stocks-table th {
    padding: 12px 8px;
    text-align: left;
    font-weight: 600;
    color: var(--primary);
    border-bottom: 2px solid var(--primary);
    white-space: nowrap;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: #e8f0fe;
    position: relative;
}

.stocks-table th:first-child {
    border-top-left-radius: 0;
}

.stocks-table th:last-child {
    border-top-right-radius: 0;
}

.stocks-table td {
    padding: 12px 8px;
    border-bottom: 1px solid #f1f3f4;
    color: var(--on-surface);
    background: inherit;
}

/* Zebra striping for better readability */
.stocks-table tbody tr:nth-child(even) {
    background: #f8f9fa;
}

.stocks-table tbody tr:nth-child(odd) {
    background: var(--surface);
}

.stocks-table tbody tr:hover {
    background: #e8f0fe !important;
    box-shadow: 0 1px 3px rgba(60,64,67,0.15);
    cursor: pointer;
}

/* Column-specific styling for better visual hierarchy */
.ticker {
    font-weight: 600;
    color: var(--primary);
    font-size: 15px;
}

/* Company name - lighter */
.stocks-table td:nth-child(3) {
    color: var(--on-surface-variant);
    font-size: 13px;
}

/* Prices - emphasized with background colors */
.stocks-table td:has(.price-low),
.stocks-table .price-low {
    background: #fef7e0;
    font-weight: 500;
    color: #ea8600;
}

.stocks-table td:has(.price-high),
.stocks-table .price-high {
    background: #e6f4ea;
    font-weight: 500;
    color: #137333;
}

.stocks-table td:has(.price-mid),
.stocks-table .price-mid {
    background: #e8f0fe;
    font-weight: 500;
    color: var(--primary);
}

/* Current price - bold and prominent */
.stocks-table tbody td:nth-child(4) {
    font-weight: 600;
    font-size: 15px;
    color: var(--primary-dark);
}

/* Market cap column */
.stocks-table tbody td:has(.market-cap-b),
.stocks-table tbody td:nth-child(12) {
    font-weight: 500;
}

/* Date column - subtle */
.stocks-table tbody td:nth-child(13) {
    color: var(--on-surface-variant);
    font-size: 13px;
}

/* Dividend amount - highlight in green */
.stocks-table tbody td:nth-child(14) {
    color: var(--secondary);
    font-weight: 600;
    font-size: 15px;
}

/* Financial metrics - monospace for numbers */
.stocks-table tbody td:nth-child(15),
.stocks-table tbody td:nth-child(16),
.stocks-table tbody td:nth-child(17) {
    font-family: 'Roboto Mono', monospace;
    font-size: 13px;
    font-weight: 600;
}

/* Good ratio badges - visual indicators */
.ratio-badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 4px;
    font-weight: 600;
    font-size: 12px;
}

.ratio-excellent {
    background: #c8e6c9;
    color: #2e7d32;
}

.ratio-good {
    background: #e8f5e9;
    color: #388e3c;
}

.ratio-fair {
    background: #fff9c4;
    color: #f57f17;
}

.ratio-poor {
    background: #ffebee;
    color: #c62828;
}

/* Add data labels for key metrics */
.stocks-table tbody td[data-label]::before {
    content: attr(data-label);
    display: none;
    font-weight: 600;
    color: var(--on-surface-variant);
    margin-right: 8px;
    font-size: 11px;
}

/* Legend styles */
.color-legend {
    display: flex;
    gap: 16px;
    margin-bottom: 16px;
    padding: 12px;
    background: #f8f9fa;
    border-radius: 8px;
    flex-wrap: wrap;
    font-size: 13px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.legend-color {
    width: 12px;
    height: 12px;
    border-radius: 3px;
    border: 1px solid;
}

/* Watchlist Star */
.watchlist-cell {
    text-align: center;
    width: 40px;
    padding: 8px !important;
}

.watchlist-star {
    font-size: 20px;
    color: var(--border);
    cursor: pointer;
    transition: all 0.2s;
    user-select: none;
    display: inline-block;
}

.watchlist-star:hover {
    color: var(--warning);
    transform: scale(1.2);
}

.watchlist-star.active {
    color: var(--warning);
}

/* Alerts Page */
.alerts-list {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
}

.alert-item {
    display: flex;
    gap: var(--spacing-md);
    padding: var(--spacing-md);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    transition: box-shadow 0.2s;
}

.alert-item:hover {
    box-shadow: var(--shadow-sm);
}

.alert-item.unread {
    background: #e8f0fe;
    border-color: var(--primary-light);
}

.alert-icon {
    font-size: 32px;
}

.alert-content {
    flex: 1;
    min-width: 0;
}

.alert-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-xs);
    gap: var(--spacing-sm);
}

.alert-ticker {
    font-weight: 500;
    font-size: 16px;
    color: var(--primary);
}

.alert-time {
    font-size: 12px;
    color: var(--on-surface-variant);
    white-space: nowrap;
}

.alert-message {
    font-size: 14px;
    color: var(--on-surface);
    margin-bottom: var(--spacing-xs);
}

.alert-details {
    font-size: 13px;
    color: var(--on-surface-variant);
}

.price-change {
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 500;
    margin-left: var(--spacing-sm);
}

.price-change.negative {
    background: #fce8e6;
    color: var(--error);
}

.alert-actions button {
    background: var(--secondary);
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 14px;
    transition: background 0.2s;
}

.alert-actions button:hover {
    background: #2d8e47;
}

.no-alerts {
    text-align: center;
    padding: 60px 20px;
    color: var(--on-surface-variant);
}

/* Telegram Settings */
.telegram-settings {
    margin-top: var(--spacing-lg);
}

.setting-description {
    margin-bottom: var(--spacing-lg);
    padding: var(--spacing-md);
    background: var(--background);
    border-radius: var(--radius);
}

.setting-description p {
    margin-bottom: var(--spacing-sm);
    color: var(--on-surface-variant);
    font-size: 14px;
}

.link-info {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
}

.link-info:hover {
    text-decoration: underline;
}

.telegram-form {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-lg);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--spacing-md);
}

/* Toggle Switch */
.toggle-switch {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    cursor: pointer;
}

.toggle-switch input[type="checkbox"] {
    display: none;
}

.toggle-slider {
    width: 44px;
    height: 24px;
    background: #bdc1c6;
    border-radius: 12px;
    position: relative;
    transition: background 0.3s;
}

.toggle-slider:before {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    background: white;
    border-radius: 50%;
    top: 3px;
    left: 3px;
    transition: transform 0.3s;
    box-shadow: var(--shadow-sm);
}

.toggle-switch input[type="checkbox"]:checked + .toggle-slider {
    background: var(--primary);
}

.toggle-switch input[type="checkbox"]:checked + .toggle-slider:before {
    transform: translateX(20px);
}

.toggle-label {
    font-size: 14px;
    font-weight: 500;
    color: var(--on-surface);
}

/* Status Messages */
.status-message {
    margin-top: var(--spacing-md);
    padding: var(--spacing-sm) var(--spacing-md);
    border-radius: var(--radius);
    text-align: center;
    font-size: 14px;
    font-weight: 500;
}

.status-success {
    color: var(--secondary);
}

.status-error {
    color: var(--error);
}

/* Tablet (768px and up) */
@media (min-width: 768px) {
    .nav-right span {
        display: block;
    }

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

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

    .form-actions {
        justify-content: space-between;
    }

    .toggle-switch {
        flex: 1;
    }
}

/* Desktop (1024px and up) */
@media (min-width: 1024px) {
    .nav-content {
        padding: 0 var(--spacing-xl);
    }

    .filter-row {
        grid-template-columns: repeat(4, 1fr);
    }

    .stocks-table th,
    .stocks-table td {
        padding: 12px 16px;
    }
}

/* Mobile Menu */
@media (max-width: 767px) {
    .menu-toggle {
        display: block;
    }

    .nav-right {
        position: fixed;
        top: 64px;
        left: 0;
        right: 0;
        background: var(--surface);
        flex-direction: column;
        align-items: stretch;
        padding: var(--spacing-md);
        box-shadow: var(--shadow-md);
        transform: translateY(-100%);
        opacity: 0;
        transition: transform 0.3s, opacity 0.3s;
        pointer-events: none;
        gap: 0;
    }

    .nav-right.active {
        transform: translateY(0);
        opacity: 1;
        pointer-events: all;
    }

    .nav-link {
        padding: 12px 16px;
        border-radius: var(--radius);
    }

    .stocks-table {
        font-size: 12px;
    }

    .stocks-table th,
    .stocks-table td {
        padding: 8px 4px;
    }

    h1 { font-size: 24px; line-height: 32px; }
    h2 { font-size: 20px; line-height: 28px; }
}

/* Print Styles */
@media print {
    .navbar,
    .filter-box,
    .btn,
    .watchlist-star {
        display: none;
    }

    .stocks-table {
        font-size: 10px;
    }
}
