/* ═══════════════════════════════════════
   RPS Stock — Dark Terminal Aesthetic
   ═══════════════════════════════════════ */

/* ── CSS Variables ── */
:root {
    --bg-primary: #0a0a0f;
    --bg-secondary: #111118;
    --bg-tertiary: #1a1a24;
    --bg-elevated: #22222e;
    --bg-hover: #2a2a38;

    --text-primary: #e8e8ed;
    --text-secondary: #8b8b9e;
    --text-muted: #5c5c6e;
    --text-accent: #64ffda;
    --text-danger: #ff5c72;

    --border-color: #2a2a38;
    --border-accent: #64ffda33;

    --accent: #64ffda;
    --accent-dim: #64ffda66;
    --accent-glow: #64ffda44;
    --blue: #5ea3ff;
    --blue-dim: #5ea3ff33;
    --orange: #ffab40;
    --orange-dim: #ffab4033;
    --red: #ff5c72;
    --red-dim: #ff5c7233;
    --green: #50fa7b;
    --green-dim: #50fa7b33;
    --purple: #c084fc;
    --purple-dim: #c084fc33;

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;

    --shadow-sm: 0 2px 8px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 24px rgba(0,0,0,0.4);
    --shadow-glow: 0 0 20px var(--accent-glow);

    --font-mono: 'JetBrains Mono', monospace;
    --font-sans: 'Noto Sans SC', sans-serif;
    --font-display: 'Space Grotesk', sans-serif;
}

/* ── Reset ── */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background: var(--bg-primary);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 14px;
    line-height: 1.5;
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* Background effect */
body::before {
    content: '';
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background:
        radial-gradient(ellipse at 20% 20%, var(--accent-glow) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 80%, var(--blue-dim) 0%, transparent 50%);
    pointer-events: none;
    z-index: -1;
}

/* ── App Container ── */
.app {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 24px;
}

/* ── Header ── */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 0;
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    background: rgba(10, 10, 15, 0.85);
    backdrop-filter: blur(20px);
    z-index: 100;
    gap: 16px;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 20px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 8px;
}

.logo-icon {
    font-size: 24px;
}

.logo-text {
    font-family: var(--font-display);
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.5px;
    color: var(--text-primary);
}

.logo-accent {
    color: var(--accent);
}

.header-stats {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--text-secondary);
    padding: 4px 12px;
    background: var(--bg-tertiary);
    border-radius: 20px;
}

.stat-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent);
}

.stat-dot.pulse {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* ── Buttons ── */
.btn {
    font-family: var(--font-sans);
    font-size: 13px;
    font-weight: 500;
    padding: 8px 18px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    line-height: 1;
}

.btn-primary {
    background: var(--accent);
    color: var(--bg-primary);
    font-weight: 600;
}
.btn-primary:hover {
    box-shadow: var(--shadow-glow);
    transform: translateY(-1px);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border-color: var(--border-color);
}
.btn-ghost:hover {
    color: var(--text-primary);
    border-color: var(--text-secondary);
}

.btn-outline {
    background: transparent;
    color: var(--accent);
    border-color: var(--accent);
}
.btn-outline:hover {
    background: var(--accent-glow);
}

.btn-glow {
    background: linear-gradient(135deg, var(--accent), #34d399);
    color: var(--bg-primary);
    font-weight: 700;
    border: none;
}
.btn-glow:hover {
    box-shadow: 0 0 30px var(--accent-glow);
    transform: translateY(-2px);
}

.btn-block {
    display: flex;
    width: 100%;
    justify-content: center;
    margin-top: 8px;
}

.btn-icon {
    font-size: 14px;
}

/* ── Market Tabs ── */
.market-tabs {
    display: flex;
    gap: 4px;
    padding: 20px 0 12px;
    border-bottom: 1px solid var(--border-color);
}

.market-tab {
    font-family: var(--font-sans);
    font-size: 15px;
    font-weight: 600;
    padding: 10px 24px;
    background: transparent;
    border: none;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.25s ease;
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
}

.market-tab:hover {
    color: var(--text-primary);
    background: var(--bg-tertiary);
}

.market-tab.active {
    color: var(--accent);
    background: var(--bg-tertiary);
}

.market-tab.active::after {
    content: '';
    position: absolute;
    bottom: -13px;
    left: 50%;
    transform: translateX(-50%);
    width: 24px;
    height: 3px;
    background: var(--accent);
    border-radius: 2px;
}

.market-flag {
    font-size: 18px;
}

.market-count {
    font-size: 11px;
    padding: 2px 8px;
    background: var(--bg-elevated);
    border-radius: 10px;
    font-weight: 400;
}

/* ── Controls Bar ── */
.controls-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 0;
    flex-wrap: wrap;
    gap: 12px;
}

.controls-left {
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
}

.controls-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.control-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Period Buttons */
.period-buttons {
    display: flex;
    align-items: center;
    gap: 2px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    padding: 2px;
}

.period-btn {
    font-family: var(--font-display);
    font-size: 13px;
    font-weight: 600;
    padding: 6px 14px;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
}
.period-btn:hover {
    color: var(--text-primary);
}
.period-btn.active {
    background: var(--accent);
    color: var(--bg-primary);
}

/* Sector Filter */
.sector-filter {
    display: flex;
    align-items: center;
    gap: 8px;
}

.control-select {
    font-family: var(--font-sans);
    font-size: 13px;
    padding: 6px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    cursor: pointer;
    min-width: 120px;
}
.control-select:focus {
    border-color: var(--accent);
    outline: none;
}

/* Search */
.search-box {
    display: flex;
    align-items: center;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 0 12px;
    transition: border-color 0.2s;
    min-width: 240px;
}
.search-box:focus-within {
    border-color: var(--accent);
}

.search-icon {
    font-size: 14px;
}

.search-input {
    font-family: var(--font-sans);
    font-size: 13px;
    padding: 8px 8px;
    background: transparent;
    border: none;
    color: var(--text-primary);
    width: 100%;
}
.search-input::placeholder {
    color: var(--text-muted);
}
.search-input:focus {
    outline: none;
}

/* ── Table ── */
.table-container {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-md);
}

.rps-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.rps-table thead {
    position: sticky;
    top: 0;
    z-index: 10;
}

.rps-table th {
    background: var(--bg-tertiary);
    padding: 14px 12px;
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

.rps-table th.sortable {
    cursor: pointer;
    transition: color 0.2s;
}
.rps-table th.sortable:hover {
    color: var(--accent);
}
.rps-table th.active-sort {
    color: var(--accent);
}

.sort-arrow {
    font-size: 10px;
    margin-left: 2px;
}

.rps-table td {
    padding: 12px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-secondary);
}

.rps-table tr:hover td {
    background: var(--bg-hover);
}

.rps-table tr.clickable {
    cursor: pointer;
}
.rps-table tr.clickable td:first-child {
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 12px;
}

.col-rank { width: 50px; text-align: center; }
.col-ticker { width: 110px; font-family: var(--font-mono); }
.col-name { width: auto; min-width: 120px; }
.col-sector { width: 100px; }
.col-price { width: 90px; text-align: right; font-family: var(--font-mono); }
.col-change { width: 80px; text-align: right; font-family: var(--font-mono); }
.col-rps { width: 90px; text-align: center; font-family: var(--font-mono); }
.col-action { width: 50px; text-align: center; }

.td-ticker {
    font-family: var(--font-mono);
    font-weight: 600;
    color: var(--text-primary) !important;
}

.td-name {
    color: var(--text-primary) !important;
    font-weight: 500;
}

.td-price {
    text-align: right;
    color: var(--text-primary) !important;
    font-weight: 500;
}

.td-change-up {
    color: var(--green) !important;
    text-align: right;
}
.td-change-down {
    color: var(--red) !important;
    text-align: right;
}

.td-rps {
    text-align: center;
    font-weight: 700;
    font-size: 14px;
}

.rps-elite   { color: var(--accent) !important; text-shadow: 0 0 10px var(--accent-glow); }
.rps-strong  { color: var(--green) !important; }
.rps-medium  { color: var(--blue) !important; }
.rps-weak    { color: var(--orange) !important; }
.rps-veryweak { color: var(--red) !important; }

.btn-fav {
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 16px;
    transition: transform 0.2s;
    opacity: 0.5;
}
.btn-fav:hover {
    transform: scale(1.3);
    opacity: 1;
}
.btn-fav.active {
    opacity: 1;
    filter: none;
}

.loading-row td {
    text-align: center;
    padding: 60px 0;
    color: var(--text-muted);
}

.loading-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border-color);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 12px;
}

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

/* ── Pagination ── */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 16px;
    padding: 24px 0;
}

.page-btn {
    font-family: var(--font-sans);
    font-size: 13px;
    padding: 8px 20px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
}
.page-btn:hover:not(:disabled) {
    background: var(--bg-elevated);
    color: var(--text-primary);
}
.page-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.page-info {
    font-size: 13px;
    color: var(--text-muted);
}

/* ── Sector Section ── */
.section {
    margin-top: 32px;
}

.sector-section {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-md);
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 24px;
    cursor: pointer;
    transition: background 0.2s;
}
.section-header:hover {
    background: var(--bg-tertiary);
}
.section-header h2 {
    font-family: var(--font-display);
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

.section-toggle {
    font-size: 12px;
    color: var(--text-muted);
    transition: transform 0.3s;
}

.sector-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
    padding: 0 24px 24px;
}

.sector-card {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px;
    cursor: pointer;
    transition: all 0.2s;
}
.sector-card:hover {
    background: var(--bg-elevated);
    border-color: var(--accent-dim);
    transform: translateY(-2px);
}

.sector-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.sector-rps {
    font-family: var(--font-display);
    font-size: 28px;
    font-weight: 700;
    color: var(--accent);
}

.sector-meta {
    display: flex;
    justify-content: space-between;
    margin-top: 8px;
    font-size: 11px;
    color: var(--text-muted);
}

.sector-hot {
    color: var(--orange);
}

/* ── Modals ── */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    padding: 24px;
}

.modal {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    width: 100%;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
    animation: modalSlideIn 0.25s ease;
}

@keyframes modalSlideIn {
    from { opacity: 0; transform: translateY(20px) scale(0.97); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-sm { max-width: 420px; }
.modal-md { max-width: 800px; }
.modal-lg { max-width: 900px; }

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    background: var(--bg-secondary);
    z-index: 1;
}

.modal-title {
    font-family: var(--font-display);
    font-size: 18px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 12px;
}

.modal-name {
    font-size: 14px;
    font-weight: 400;
    color: var(--text-secondary);
}

.modal-close {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 20px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
}
.modal-close:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

.modal-body {
    padding: 24px;
}

/* Stock Overview */
.stock-overview {
    display: flex;
    gap: 24px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 24px;
}

.overview-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.overview-label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.overview-value {
    font-family: var(--font-mono);
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

/* RPS Cards */
.rps-cards {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 24px;
}

.rps-card {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 20px;
    text-align: center;
    transition: all 0.2s;
}
.rps-card:hover {
    border-color: var(--accent-dim);
}

.rps-card-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 8px;
}

.rps-card-value {
    font-family: var(--font-display);
    font-size: 36px;
    font-weight: 700;
    margin-bottom: 4px;
}

.rps-card-ret {
    font-size: 12px;
    color: var(--text-muted);
}

.rps-card-tag {
    display: inline-block;
    margin-top: 8px;
    padding: 2px 10px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
}

/* Chart */
.rps-chart-container {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 24px;
    min-height: 300px;
    position: relative;
}

.chart-locked {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 300px;
    gap: 12px;
    color: var(--text-muted);
}

.lock-icon {
    font-size: 48px;
    filter: grayscale(0.5);
}

.chart-locked p {
    font-size: 14px;
    color: var(--text-secondary);
}

canvas#rpsChart {
    width: 100% !important;
    height: 300px !important;
}

/* ── Auth ── */
.auth-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 24px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    padding: 2px;
}

.auth-tab {
    flex: 1;
    font-family: var(--font-sans);
    font-size: 14px;
    font-weight: 500;
    padding: 10px;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
}
.auth-tab:hover {
    color: var(--text-primary);
}
.auth-tab.active {
    background: var(--accent);
    color: var(--bg-primary);
    font-weight: 600;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.form-group input {
    width: 100%;
    font-family: var(--font-sans);
    font-size: 14px;
    padding: 10px 14px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    transition: border-color 0.2s;
}
.form-group input:focus {
    border-color: var(--accent);
    outline: none;
}

.form-error {
    background: var(--red-dim);
    border: 1px solid var(--red);
    color: var(--red);
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    margin-bottom: 16px;
}

/* ── User Menu ── */
.user-menu {
    position: relative;
}

.user-avatar {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    color: var(--bg-primary);
}

.user-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 8px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    min-width: 180px;
    box-shadow: var(--shadow-md);
    z-index: 300;
    overflow: hidden;
}

.user-dropdown button {
    display: block;
    width: 100%;
    text-align: left;
    padding: 12px 16px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}
.user-dropdown button:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.user-dropdown-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
}

.plan-badge {
    font-size: 11px;
    font-weight: 600;
    padding: 2px 10px;
    border-radius: 10px;
}
.plan-badge.free    { background: var(--bg-elevated); color: var(--text-muted); }
.plan-badge.premium { background: var(--purple-dim); color: var(--purple); }
.plan-badge.vip     { background: var(--orange-dim); color: var(--orange); }

/* ── Pricing ── */
.pricing-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

.pricing-card {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 24px;
    text-align: center;
    position: relative;
    transition: all 0.3s;
}
.pricing-card:hover {
    transform: translateY(-4px);
}

.pricing-card-featured {
    border-color: var(--accent);
    box-shadow: 0 0 30px var(--accent-glow);
}

.pricing-badge {
    position: absolute;
    top: -12px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--accent);
    color: var(--bg-primary);
    font-size: 11px;
    font-weight: 700;
    padding: 4px 16px;
    border-radius: 12px;
}

.pricing-header {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.pricing-price {
    font-family: var(--font-display);
    font-size: 40px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 12px 0 4px;
}

.pricing-period {
    font-size: 14px;
    font-weight: 400;
    color: var(--text-muted);
}

.pricing-yearly {
    font-size: 12px;
    color: var(--accent);
    margin-bottom: 16px;
}

.pricing-features {
    list-style: none;
    text-align: left;
    margin-bottom: 20px;
}

.pricing-features li {
    padding: 6px 0;
    font-size: 12px;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-color);
}
.pricing-features li:last-child {
    border-bottom: none;
}

.payment-note {
    margin-top: 20px;
    font-size: 12px;
    color: var(--text-muted);
    text-align: center;
}

/* ── Utilities ── */
.hidden { display: none !important; }

/* ── Responsive ── */
@media (max-width: 900px) {
    .pricing-grid {
        grid-template-columns: 1fr;
    }
    .rps-cards {
        grid-template-columns: repeat(2, 1fr);
    }
    .stock-overview {
        flex-direction: column;
        gap: 12px;
    }
    .controls-bar {
        flex-direction: column;
        align-items: flex-start;
    }
    .rps-table th, .rps-table td {
        padding: 8px 6px;
        font-size: 11px;
    }
}

@media (max-width: 600px) {
    .header {
        flex-direction: column;
        align-items: flex-start;
    }
    .market-tabs {
        overflow-x: auto;
    }
    .period-buttons {
        overflow-x: auto;
    }
}
