* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Arial, sans-serif;
    background: #111827;
    color: white;
    height: 100vh;
    overflow: hidden;
}

button,
input {
    font: inherit;
}

button {
    cursor: pointer;
}

.app-layout {
    display: flex;
    width: 100%;
    height: 100vh;
}


/* SIDEBAR */

.sidebar {
    width: 270px;
    background: #0f172a;
    padding: 24px;
    display: flex;
    flex-direction: column;
    border-right: 1px solid #1f2937;
    overflow-y: auto;
}

.sidebar h2 {
    margin: 0 0 22px;
    font-size: 24px;
}

.new-chat-btn {
    width: 100%;
    padding: 12px;
    margin: 0 0 26px;

    border: none;
    border-radius: 10px;

    background: #2563eb;
    color: white;

    font-size: 15px;
}

.new-chat-btn:hover {
    background: #1d4ed8;
}


/* CONVERSATIONS */

.conversation-section {
    margin-bottom: 24px;
}

.conversation-section h3 {
    margin: 0 0 10px;

    color: #94a3b8;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

#conversation-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.conversation-row {
    display: flex;
    align-items: stretch;
    gap: 5px;
}

.conversation-row .conversation-button {
    flex: 1;
}

.conversation-button {
    width: 100%;
    padding: 10px;

    margin: 0;

    border: none;
    border-radius: 8px;

    background: transparent;
    color: #e2e8f0;

    text-align: left;
    font-size: 14px;
}

.conversation-button:hover {
    background: #1e293b;
}

.delete-conversation-button {
    width: 34px;
    padding: 0;
    margin: 0;

    border: none;
    border-radius: 8px;

    background: transparent;
    color: #94a3b8;

    font-size: 20px;
}

.delete-conversation-button:hover {
    background: #7f1d1d;
    color: white;
}


/* SIDEBAR NAVIGATION */

.sidebar-menu {
    display: flex;
    flex-direction: column;
    gap: 6px;

    margin-top: auto;
}

.nav-button {
    width: 100%;
    padding: 12px;

    margin: 0;

    border: none;
    border-radius: 9px;

    background: transparent;
    color: #cbd5e1;

    text-align: left;
    font-size: 15px;

    transition:
        background 0.2s ease,
        color 0.2s ease;
}

.nav-button:hover {
    background: #1e293b;
    color: white;
}

.nav-button.active {
    background: #1e3a8a;
    color: white;
}


/* MAIN AREA */

.main-area {
    flex: 1;
    min-width: 0;
    height: 100vh;

    background: #111827;

    overflow: hidden;
}

.page {
    display: none;
    width: 100%;
    height: 100%;
    overflow-y: auto;
}

.page.active-page {
    display: flex;
    flex-direction: column;
}


/* HEADERS */

.chat-header,
.page-header {
    padding: 24px 30px;

    border-bottom: 1px solid #374151;
}

.chat-header h1,
.page-header h1 {
    margin: 0 0 7px;

    font-size: 30px;
}

.chat-header p,
.page-header p {
    margin: 0;

    color: #94a3b8;
}


/* CHAT */

#chat-page {
    height: 100%;
}

#chat-box {
    flex: 1;

    width: 100%;

    padding: 24px;

    overflow-y: auto;
}

.message {
    max-width: 850px;

    padding: 14px 16px;

    margin-bottom: 14px;

    border-radius: 12px;

    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.user-message {
    margin-left: auto;

    background: #2563eb;
    color: white;

    text-align: left;
}

.ai-message {
    margin-right: auto;

    background: #1f2937;
    color: white;
}

.input-area {
    display: flex;
    gap: 10px;

    padding: 18px 24px;

    border-top: 1px solid #374151;

    background: #111827;
}

.input-area input {
    flex: 1;
    min-width: 0;

    padding: 14px 16px;

    border: 1px solid #374151;
    border-radius: 10px;

    background: #1f2937;
    color: white;

    outline: none;
}

.input-area input:focus {
    border-color: #2563eb;
}

.input-area button {
    padding: 13px 22px;

    margin: 0;

    border: none;
    border-radius: 10px;

    background: #2563eb;
    color: white;
}

.input-area button:hover {
    background: #1d4ed8;
}


/* DASHBOARD */

.portfolio-summary {
    display: grid;

    grid-template-columns:
        repeat(3, minmax(0, 1fr));

    gap: 16px;

    padding: 28px 30px 10px;
}

.dashboard-card {
    padding: 20px;

    border: 1px solid #374151;
    border-radius: 14px;

    background: #1f2937;
}

.dashboard-card span {
    display: block;

    margin-bottom: 8px;

    color: #94a3b8;
    font-size: 14px;
}

.dashboard-card h2 {
    margin: 0;

    font-size: 28px;
}

.dashboard-section {
    margin: 18px 30px;

    padding: 22px;

    border: 1px solid #374151;
    border-radius: 14px;

    background: #1f2937;
}

.dashboard-section h2 {
    margin-top: 0;
    margin-bottom: 18px;
}

#portfolio-positions,
#portfolio-history {
    color: #cbd5e1;

    white-space: pre-wrap;
}


/* MARKETS */

.market-search {
    display: flex;
    gap: 10px;

    padding: 28px 30px 10px;
}

.market-search input {
    flex: 1;

    padding: 14px 16px;

    border: 1px solid #374151;
    border-radius: 10px;

    background: #1f2937;
    color: white;

    outline: none;
}

.market-search input:focus {
    border-color: #2563eb;
}

.market-search button {
    padding: 13px 24px;

    margin: 0;

    border: none;
    border-radius: 10px;

    background: #2563eb;
    color: white;
}

.market-search button:hover {
    background: #1d4ed8;
}

#market-results {
    margin: 20px 30px;

    padding: 22px;

    border: 1px solid #374151;
    border-radius: 14px;

    background: #1f2937;

    color: #cbd5e1;
}


/* STOCK CHART */

.stock-chart-container {
    width: 100%;
    height: 320px;

    margin-top: 20px;
}


/* GENERAL PAGE CONTENT */

.page-header + p {
    padding: 20px 30px;
}


/* MOBILE */

@media (max-width: 768px) {

    body {
        height: auto;
        min-height: 100vh;

        overflow: auto;
    }

    .app-layout {
        flex-direction: column;
        min-height: 100vh;
        height: auto;
    }

    .sidebar {
        width: 100%;

        padding: 16px;

        border-right: none;
        border-bottom: 1px solid #1f2937;
    }

    .sidebar h2 {
        margin-bottom: 15px;
    }

    .new-chat-btn {
        margin-bottom: 16px;
    }

    .conversation-section {
        margin-bottom: 16px;
    }

    .sidebar-menu {
        display: grid;

        grid-template-columns:
            repeat(2, minmax(0, 1fr));

        margin-top: 10px;
    }

    .main-area {
        height: auto;
        min-height: 70vh;

        overflow: visible;
    }

    .page {
        min-height: 70vh;
        height: auto;
    }

    .chat-header,
    .page-header {
        padding: 18px;
    }

    .chat-header h1,
    .page-header h1 {
        font-size: 26px;
    }

    #chat-box {
        min-height: 350px;

        padding: 16px;
    }

    .input-area {
        padding: 12px;
    }

    .input-area button {
        padding: 12px 16px;
    }

    .message {
        max-width: 88%;
    }

    .portfolio-summary {
        grid-template-columns: 1fr;

        padding: 20px 18px 6px;
    }

    .dashboard-section {
        margin: 14px 18px;
    }

    .market-search {
        flex-direction: column;

        padding: 20px 18px 6px;
    }

    .market-search button {
        width: 100%;
    }

    #market-results {
        margin: 14px 18px;
    }

    .stock-chart-container {
        height: 260px;
    }
}

/* AUTHENTICATION */

.auth-body {
    margin: 0;
    min-height: 100vh;

    display: flex;
    align-items: center;
    justify-content: center;

    background: #111827;
    color: white;

    overflow: auto;
}

.auth-container {
    width: 100%;
    max-width: 460px;

    padding: 24px;
}

.auth-card {
    padding: 34px;

    background: #1f2937;

    border: 1px solid #374151;
    border-radius: 16px;
}

.auth-card h1 {
    margin: 0 0 8px;

    text-align: center;
}

.auth-subtitle {
    margin: 0 0 28px;

    text-align: center;
    color: #94a3b8;
}

.auth-card form {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.auth-card label {
    margin-top: 8px;

    color: #cbd5e1;

    font-size: 14px;
}

.auth-card input {
    width: 100%;

    padding: 13px 14px;

    border: 1px solid #374151;
    border-radius: 10px;

    background: #111827;
    color: white;

    outline: none;
}

.auth-card input:focus {
    border-color: #2563eb;
}

.auth-button {
    width: 100%;

    margin-top: 18px;

    padding: 13px;

    border: none;
    border-radius: 10px;

    background: #2563eb;
    color: white;
}

.auth-button:hover {
    background: #1d4ed8;
}

.auth-switch {
    margin: 24px 0 0;

    text-align: center;

    color: #94a3b8;
}

.auth-switch a {
    color: #60a5fa;
    text-decoration: none;
}

.auth-switch a:hover {
    text-decoration: underline;
}

.auth-message {
    padding: 10px 14px;

    margin-bottom: 18px;

    border: 1px solid #7f1d1d;
    border-radius: 9px;

    background: #450a0a;
}

.auth-message p {
    margin: 0;

    color: #fecaca;
}

.modal {
    display: none;

    position: fixed;

    top: 0;
    left: 0;

    width: 100%;
    height: 100%;

    background: rgba(0,0,0,.65);

    justify-content: center;
    align-items: center;

    z-index: 9999;
}

.modal-content {

    width: 450px;

    background: #1f2937;

    padding: 30px;

    border-radius: 18px;

    display: flex;
    flex-direction: column;
    gap: 15px;
}

.modal-content input,
.modal-content textarea {

    width: 100%;

    padding: 12px;

    border: none;

    border-radius: 10px;

    background: #111827;

    color: white;

    box-sizing: border-box;
}

.modal-content textarea {

    height: 120px;

    resize: none;
}

.modal-buttons {

    display: flex;

    justify-content: flex-end;

    gap: 10px;
}