/* ============================================
   PlayTrade - Shared Styles
   ============================================ */

/* CSS Variables */
:root {
    --dark-color: #001f3f;
    --medium-color: #003d6b;
    --mid-color: #a8cef3;
    --light-color: #e8f4f8;
    --accent-color: #00ffcc;
    --white-color: #ffffff;
    --black-color: #000000;
    --app-max-width: 1000px;

    --success-color: #62ff87;
    --fail-color: #fe6262;
}

/* Reset & Base */
*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: "Inter", sans-serif;
    font-optical-sizing: auto;
    font-weight: normal;
    font-style: normal;
    margin: 0;
    padding: 0;
    background-color: var(--dark-color);
    color: var(--white-color);
    font-size: 16px;
    line-height: 1.6;
}

h1,
h2,
summary {
    margin: 0;
    color: var(--light-color);
    font-weight: bold;
}

h2,
summary {
    font-size: 2.2em;
    line-height: 1em;
    margin-bottom: 1rem;
}

/* Forms */
label {
    display: block;
    margin-bottom: 1.5rem;
}

label span {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--dark-color);
    font-weight: 500;
}

input {
    font-family: inherit;
    font-size: 1em;
    padding: 0.75rem;
    width: 100%;
    border: 2px solid var(--light-color);
    border-radius: 4px;
    transition: border-color 0.3s;
}

input:focus {
    outline: none;
    border-color: var(--accent-color);
}

/* Buttons */
button {
    font-family: inherit;
    background-color: var(--accent-color);
    color: var(--black-color);
    border: none;
    padding: 0.75rem 1.5rem;
    font-size: 1em;
    cursor: pointer;
    border-radius: 4px;
    font-weight: 600;
    transition: transform 0.2s, box-shadow 0.2s;
}

button:hover {
    transform: translateY(-2px);
}

button:active {
    transform: translateY(0);
}

#holdings-body td:has(button) {
    display:flex !important;
    flex-direction: column;
    gap: 0.5rem;
}

#holdings-body button {
    font-size: .8em;
    padding: 0.5rem;
}

/* Messages */
.message {
    margin-top: 1rem;
    padding: 0.75rem;
    border-radius: 4px;
    text-align: center;
    display: none;
}

.message.error {
    background-color: #ffe6e6;
    color: #c41e1e;
    border: 1px solid #c41e1e;
}

.message.success {
    background-color: #e6f7f5;
    color: #0d7a6d;
    border: 1px solid #0d7a6d;
}

.message.show {
    display: block;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 2rem;
    border-bottom: 2px solid var(--light-color);
}

.tab {
    flex: 1;
    padding: 0.75rem;
    text-align: center;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1em;
    color: var(--medium-color);
    font-weight: 500;
    position: relative;
    transition: color 0.3s;
    border-radius: 0;
}

.tab:hover {
    transform: none;
    box-shadow: none;
}

.tab.active {
    color: var(--dark-color);
}

.tab.active::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    right: 0;
    height: 2px;
    background-color: var(--accent-color);
}

.form-container {
    display: none;
}

.form-container.active {
    display: block;
}

.password-hint {
    font-size: 0.85em;
    color: var(--medium-color);
    margin-top: 0.25rem;
}

/* ============================================
   Landing Page Styles (login.html)
   ============================================ */

/* Hero Section */
.hero {
    background: linear-gradient(135deg, var(--dark-color) 0%, var(--medium-color) 100%);
    color: var(--white-color);
    padding: 4rem 1.5rem;
    text-align: center;
    min-height: 60vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.hero-logo {
    width: 120px;
    margin-bottom: 1.5rem;
    filter: brightness(0) invert(1);
}

.hero h1 {
    font-size: 3rem;
    margin: 0 0 1rem;
    font-weight: 700;
    color: var(--white-color);
}

.hero-tagline {
    font-size: 1.25rem;
    opacity: 0.9;
    max-width: 600px;
    margin: 0 auto 2rem;
}

.hero-cta {
    display: inline-block;
    background-color: var(--accent-color);
    color: var(--black-color);
    padding: 1rem 2.5rem;
    border-radius: 4px;
    text-decoration: none;
    font-weight: 600;
    font-size: 1.1rem;
    transition: transform 0.2s, box-shadow 0.2s;
}

.hero-cta:hover {
    transform: translateY(-3px);
}

/* Features Section */
.features {
    padding: 4rem 1.5rem;
    max-width: 1200px;
    margin: 0 auto;
}

.section-title {
    text-align: center;
    color: var(--dark-color);
    font-size: 2rem;
    margin-bottom: 3rem;
}

.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 2rem;
}

.feature-card {
    background: var(--light-color);
    padding: 2rem;
    border-radius: 4px;
    text-align: center;
    transition: transform 0.3s, box-shadow 0.3s;
}

.feature-card:hover {
    transform: translateY(-5px);
}

.feature-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.feature-card h3 {
    color: var(--dark-color);
    margin: 0 0 0.75rem;
    font-size: 1.25rem;
}

.feature-card p {
    color: #555;
    margin: 0;
    font-size: 0.95rem;
}

/* How It Works Section */
.how-it-works {
    background: var(--light-color);
    padding: 4rem 1.5rem;
}

.steps {
    max-width: 800px;
    margin: 0 auto;
}

.step {
    display: flex;
    align-items: flex-start;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.step-number {
    flex-shrink: 0;
    width: 30px;
    height: 30px;
    border: 2px solid var(--dark-color);
    background: transparent;
    color: var(--dark-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.25rem;
}

.step-content h3 {
    color: var(--dark-color);
    margin: 0 0 0.5rem;
}

.step-content p {
    color: #555;
    margin: 0;
}

/* Why Section */
.why-playtrade {
    padding: 4rem 1.5rem;
    max-width: 900px;
    margin: 0 auto;
    text-align: center;
}

.why-playtrade p {
    font-size: 1.1rem;
    color: #444;
    margin-bottom: 1.5rem;
}

.highlight-box {
    background: linear-gradient(135deg, var(--dark-color) 0%, var(--medium-color) 100%);
    color: var(--white-color);
    padding: 2rem;
    border-radius: 4px;
    margin: 2rem 0;
}

.highlight-box p {
    color: var(--white-color);
    margin: 0;
    font-size: 1.15rem;
}

/* Auth Section */
.auth-section {
    background: var(--light-color);
    padding: 4rem 1.5rem;
}

.auth-container {
    background-color: var(--white-color);
    padding: 3rem 2rem;
    border-radius: 4px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
    max-width: 450px;
    margin: 0 auto;
}

.auth-header {
    text-align: center;
    margin-bottom: 2rem;
}

.auth-header h2 {
    color: var(--dark-color);
    margin: 0 0 0.5rem;
    font-size: 1.75rem;
}

.auth-header p {
    color: #666;
    margin: 0;
}

/* Landing Page Footer */
.landing-footer {
    text-align: center;
    padding: 2rem 1.5rem;
    color: #666;
    font-size: 0.9rem;
}

/* ============================================
   App UI Styles (ui.html)
   ============================================ */

/* App Layout */
.app-body {
    line-height: 1.5;
}

.app-header {
    padding: 2rem;
    width: 100%;
    max-width: var(--app-max-width);
    height: 90px;
    margin: auto;
    text-align: center;
    background-color: var(--dark-color);
    color: var(--light-color);
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: center;
    font-size: 0.75rem;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 4;
}

.app-footer {
    padding: 0.5rem 2rem;
    width: 100%;
    height: 74px;
    margin: auto;
    text-align: center;
    background-color: rgb(0 0 0 / 0.2);
    color: var(--light-color);
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 4;
}

.app-main {
    width: 100%;
    max-width: var(--app-max-width);
    margin: auto;
    display: flex;
    flex-direction: column;
    gap: 0;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
}

#logo {
    width: 70px;
}

.app-main section {
    position: fixed;
    z-index: 1;
    top: 74px;
    bottom: 74px;
    left: 0;
    right: 0;
    max-width: var(--app-max-width);
    margin: 0 auto;
    padding: 2rem;
    background-color: var(--dark-color);
    overflow-y: auto;
}

section#portfolio-section {
    z-index: 2;
}

/* Portfolio Charts */
.portfolio-charts {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0;
    margin-top: 1rem;
}

.portfolio-charts .chart-container {
    min-width: 0;
    text-align: left;
}

.portfolio-charts .chart-container h3 {
    font-size: 1rem;
    margin-bottom: 0.5rem;
    color: var(--light-color);
}

.stacked-bar {
    display: flex;
    height: 28px;
    border-radius: 8px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.06);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.stacked-bar.is-empty {
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.85rem;
}

.bar-segment {
    height: 100%;
}

.stacked-legend {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 0.5rem 1rem;
    margin-top: 0.75rem;
    color: rgba(255, 255, 255, 0.78);
    font-size: 0.85rem;
}

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

.legend-swatch {
    width: 16px;
    height: 10px;
    border-radius: 2px;
    flex: 0 0 auto;
}

.legend-label {
    flex: 1;
}

.legend-value {
    opacity: 0.75;
}

body.portfolio section#portfolio-section,
body.find section#find-section,
body.holdings section#holdings-section,
body.recent-trades section#recent-trades-section,
body.actions section#actions-section,
body.stock-detail section#stock-detail-section {
    z-index: 3;
}

body.actions section#actions-section {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

/* App Forms */
.app-body label {
    display: flex;
    flex-direction: column;
    width: 100%;
    margin-bottom: 0;
}

.app-body input {
    margin: 0.5rem 0;
    border: 1px solid var(--medium-color);
    border-radius: 0;
}

.app-body button {
    margin: 0.5rem 0.5rem 0 0;
    width: 100%;
    border-radius: 0;
}

/* Tables */
table {
    font-feature-settings: "tnum";
    text-align: left;
    width: 100%;
    border-collapse: collapse;
}

table tr td,
table tr th {
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--medium-color);
}

table#portfolio-summary tr td:last-of-type {
    text-align: right;
}

table.responsive thead {
    display: none;
}

table.responsive tr {
    display: block;
    margin-bottom: 2rem;
}

table.responsive tr td {
    display: flex;
    justify-content: space-between;
    width: 100%;
    text-align: right;
}

table.responsive tr td:not(:has(button))::before {
    content: attr(data-label);
    font-weight: bold;
    width: 120px;
    display: inline-block;
    text-align: left;
}

/* Navigation */
ul.nav {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    gap: .5rem;
}

ul.nav li {
    cursor: pointer;
    font-size: .6rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.125rem;
}

ul.nav li > svg {
    pointer-events: none;
}

.app-footer ul.nav {
    width: 100%;
    max-width: var(--app-max-width);
    margin: 0 auto;
    justify-content: space-around;
}

.icon {
    width: 32px;
    height: 32px;
    stroke: var(--light-color);
    stroke-width: 6;
}

.icon > * {
  stroke-width: 6;
  stroke-linejoin: round;
  stroke-linecap: round;
}

/* Holdings List */
.holdings-list {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.holding-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 0;
    background: var(--dark-color);
    border-bottom: 1px solid var(--medium-color);
    cursor: pointer;
    transition: background-color 0.2s;
}

.holding-item:first-child {
    border-radius: 8px 8px 0 0;
}

.holding-item:last-child {
    border-bottom: none;
    border-radius: 0 0 8px 8px;
}

.holding-item:only-child {
    border-radius: 8px;
}

.holding-item:active {
    background-color: #e8ddf0;
}

.holding-main {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.holding-symbol {
    font-weight: 700;
    color: var(--light-color);
    font-size: 1.1rem;
}

.market-closed-badge {
    display: inline-block;
    margin-left: 0.5rem;
    padding: 0.15rem 0.4rem;
    font-size: 0.65rem;
    font-weight: 600;
    background-color: #e0e0e0;
    color: #666;
    border-radius: 3px;
    vertical-align: middle;
}

.holding-name {
    font-size: 0.85rem;
    color: var(--mid-color);
    max-width: 200px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.holding-data {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.25rem;
}

.holding-price {
    font-weight: 600;
    color: var(--light-color);
}

.holding-change {
    font-size: 0.9rem;
    font-weight: 600;
}

.no-holdings {
    text-align: center;
    color: #666;
    padding: 2rem;
    background: var(--dark-color);
    border-radius: 8px;
}

.feature-card .icon {
  width: 80px;
  height: 80px;
}

.feature-card .icon .line-item {
  stroke: var(--dark-color);
  stroke-width: 3;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ============================================
   Stock Detail View
   ============================================ */

.stock-detail-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stock-detail-header h2 {
    margin-bottom: 0;
}

.back-btn {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    background-color: var(--light-color);
    color: var(--dark-color);
}

.back-btn:hover {
    background-color: var(--medium-color);
    color: var(--white-color);
}

.chart-container {
    background: transparent;
    border-radius: 8px;
    padding: 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.period-selector {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.period-btn {
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
    background-color: var(--light-color);
    color: var(--dark-color);
    border: 2px solid transparent;
}

.period-btn:hover {
    background-color: var(--medium-color);
    color: var(--white-color);
    transform: none;
}

.period-btn.active {
    background-color: var(--accent-color);
    color: var(--black-color);
    border-color: var(--dark-color);
}

.chart-wrapper {
    position: relative;
    height: 300px;
    transition: opacity 0.3s;
}

.chart-loading,
.chart-error {
    text-align: center;
    padding: 1rem;
    color: var(--medium-color);
}

.chart-error {
    color: #c41e1e;
    display: none;
}

.chart-loading {
    display: none;
}

.stock-info-table {
    margin-top: 1.5rem;
    background: var(--dark-color);
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    overflow: hidden;
}

.stock-info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--medium-color);
}

.stock-info-row:last-child {
    border-bottom: none;
}

.stock-info-label {
    font-weight: 600;
    color: var(--light-color);
}

.stock-info-value {
    text-align: right;
    color: var(--light-color);
}

/* Stock Actions Panel */
.stock-actions-panel {
    margin-top: 1.5rem;
    background: var(--dark-color);
    border-radius: 8px;
    padding: 1.5rem 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.stock-actions-panel h3 {
    margin: 0 0 1rem;
    color: var(--light-color);
    font-size: 1.2rem;
}

.action-group {
    margin-bottom: 1rem;
}

.action-group:last-child {
    margin-bottom: 0;
}

.action-label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--light-color);
    font-size: 0.9rem;
}

.action-input-row {
    display: flex;
    gap: 0.5rem;
}

.action-input-row input {
    flex: 1;
    padding: 0.75rem;
    border: 1px solid var(--medium-color);
    border-radius: 4px;
    font-size: 1rem;
}

.action-btn {
    padding: 0.75rem 1.5rem;
    font-weight: 600;
    border-radius: 4px;
}

.action-btn.sell-btn {
    background-color: #e74c3c;
    color: var(--white-color);
}

.action-btn.sell-btn#detail-sell-all-btn,
.action-btn.sell-btn#find-sell-all-btn {
    width:100%;
}

.action-btn.sell-btn:hover {
    background-color: #c0392b;
}

.action-btn.buy-btn {
    background-color: #27ae60;
    color: var(--white-color);
}

.action-btn.buy-btn:hover {
    background-color: #1e8449;
}

.trade-message {
    padding: 0.75rem;
    border-radius: 4px;
    margin-bottom: 1rem;
    display: none;
}

.trade-message.show {
    display: block;
}

.trade-message.success {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.trade-message.error {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

/* ============================================
   Find Section
   ============================================ */

.find-loading {
    text-align: center;
    padding: 1rem;
    color: var(--mid-color);
}

.find-results-list {
    display: flex;
    flex-direction: column;
    gap: 0;
    margin-top: 1rem;
}

.find-result-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 0;
    border-bottom: 1px solid var(--medium-color);
}

.find-result-item:last-child {
    border-bottom: none;
}

.find-result-info {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    min-width: 0;
    flex: 1;
}

.find-result-symbol {
    font-weight: 700;
    color: var(--light-color);
    font-size: 1.1rem;
}

.find-result-name {
    font-size: 0.85rem;
    color: var(--mid-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.find-result-exchange {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.4);
}

.find-result-item .action-btn {
    flex-shrink: 0;
    margin-left: 1rem;
    padding: 0.5rem 1.25rem;
    font-size: 0.85rem;
}

.find-quote-info {
    margin-bottom: 1rem;
}

.find-quote-info .stock-info-table {
    margin-top: 0;
}

.find-no-results {
    text-align: center;
    padding: 2rem;
    color: var(--mid-color);
}

@media (min-width: 700px) {
    .chart-wrapper {
        height: 400px;
    }
}

/* ============================================
   Responsive Styles
   ============================================ */

/* Landing Page Responsive */
@media (max-width: 768px) {
    .hero {
        padding: 3rem 1rem;
        min-height: auto;
    }

    .hero h1 {
        font-size: 2.25rem;
    }

    .hero-tagline {
        font-size: 1.1rem;
    }

    .features,
    .why-playtrade {
        padding: 3rem 1rem;
    }

    .section-title {
        font-size: 1.75rem;
    }

    .step {
        flex-direction: column;
        text-align: center;
        align-items: center;
    }

    .auth-container {
        padding: 2rem 1.5rem;
    }
}

@media (max-width: 480px) {
    .hero h1 {
        font-size: 1.85rem;
    }

    .hero-tagline {
        font-size: 1rem;
    }

    .hero-cta {
        padding: 0.85rem 2rem;
        font-size: 1rem;
    }

    .feature-card {
        padding: 1.5rem;
    }

    .highlight-box {
        padding: 1.5rem;
    }
}

/* App UI Responsive */
@media (min-width: 700px) {
    table.responsive thead {
        display: table-header-group;
    }

    table.responsive tr {
        display: table-row;
        margin-bottom: 0;
    }

    table.responsive tr td {
        display: table-cell;
        text-align: left;
    }

    table.responsive tr td::before {
        content: none !important;
    }

    table tr td,
    table tr th {
        padding: 0.5rem;
    }

    .app-body button {
        width: auto;
    }

    .action-btn.sell-btn#detail-sell-all-btn,
    .action-btn.sell-btn#find-sell-all-btn {
        width:auto;
    }
}
