/* ==========================================================
   BASE / GLOBAL (Dark App Theme)
   ========================================================== */

body {
    font-family: Inter, system-ui, sans-serif;
    background: #0e1117;
    color: #e6edf3;
    padding: 40px;
}

/* ==========================================================
   CONTAINER (FORM PAGES)
   ========================================================== */
/* Wide enough for Add Trade / Add Account */

.container {
    max-width: 1020px;            /* ← RESTORED */
    margin: 0 auto;
    background: #0f141c;
    padding: 30px 32px;
    border-radius: 12px;
    border: 1px solid #30363d;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
}

/* ==========================================================
   FORM GRID (CRITICAL – RESTORES 3-COLUMN LAYOUT)
   ========================================================== */

.form-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    column-gap: 32px;   /* 👈 clearer separation */
    row-gap: 22px;
}

/* Section headers inside grid */
.form-grid .section {
    grid-column: 1 / -1;
    margin: 10px 0 4px;
}

.form-grid .section h2 {
    font-size: 18px;
    font-weight: 600;
    color: #c9d1d9;
    border-bottom: 1px solid #30363d;
    padding-bottom: 6px;
}

/* ==========================================================
   FORM GROUPS
   ========================================================== */

.form-group {
    display: flex;
    flex-direction: column;
}

/* Labels (tight, consistent) */
.form-group label {
    margin: 0 0 6px;
    font-size: 13px;
    font-weight: 500;
    color: #9da7b3;
}

/* Inputs */
input,
select,
textarea {
    background: #161b22;
    border: 1px solid #30363d;
    color: #e6edf3;
    padding: 10px 12px;
    border-radius: 6px;
    font-size: 13px;
    width: 100%;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: #d97706;
    box-shadow: 0 0 0 1px rgba(217, 119, 6, 0.35);
}

textarea {
    resize: vertical;
    min-height: 90px;
}

/* ==========================================================
   FULL-WIDTH ROWS (already used in your HTML)
   ========================================================== */

.form-grid .span-2 {
    grid-column: span 2;
}

.form-grid .span-3,
.form-grid .full {
    grid-column: 1 / -1;
}

/* ==========================================================
   PRIMARY BUTTONS (ONLY CHANGE FROM OLD CSS)
   ========================================================== */

button {
    background: #d97706;          /* ORANGE – FIXED */
    color: #ffffff;
    border: none;
    padding: 12px 26px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: background 0.15s ease, transform 0.05s ease;
}

button:hover {
    background: #f59e0b;
}

button:active {
    transform: translateY(1px);
}

button:disabled {
    background: #7c4a03;
    cursor: not-allowed;
    opacity: 0.6;
}

/* ==========================================================
   ERROR / FEEDBACK
   ========================================================== */

.error {
    background: #3d0d13;
    color: #ffb3b3;
    padding: 12px;
    border-radius: 6px;
    margin-bottom: 15px;
    border: 1px solid #7a1c24;
}

/* ==========================================================
   TOP ACTIONS (USED AS-IS IN YOUR HTML)
   ========================================================== */

.top-actions {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 14px;
}

.top-actions button {
    padding: 8px 16px;
    font-size: 13px;
}

/* ==========================================================
   BACK LINK
   ========================================================== */

.back {
    margin-top: 18px;
    text-align: center;
}

.back a {
    text-decoration: none;
    color: #8b949e;
    font-size: 13px;
}

.back a:hover {
    color: #c9d1d9;
    text-decoration: underline;
}
/* ==========================================================
   IMAGE UPLOAD THUMBNAILS (TRADE SCREENSHOTS)
   ========================================================== */

#imagePreview {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

/* Thumbnail wrapper (JS usually injects img directly) */
#imagePreview img {
    width: 90px;
    height: 90px;

    object-fit: cover;          /* crop, don’t stretch */
    border-radius: 6px;

    border: 1px solid #30363d;
    background: #161b22;

    display: block;
}
/* ==========================================================
   IMAGE THUMBNAIL DELETE ACTION
   ========================================================== */

/* Any clickable delete control inside thumbnail */
#imagePreview .delete,
#imagePreview .remove,
#imagePreview .delete-btn,
#imagePreview button,
#imagePreview [role="button"] {
    cursor: pointer;
}

/* If delete icon is an <i> or <span> */
#imagePreview i,
#imagePreview span {
    cursor: pointer;
}
/* ================================
   DASHBOARD
================================ */
.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
}

.dashboard-header h1 {
    font-size: 24px;
    font-weight: 700;
}

.dashboard-actions {
    display: flex;
    gap: 10px;
    align-items: center;
    justify-content: flex-end;
}

/* BUTTONS */
.btn {
    padding: 10px 16px;
    border-radius: 6px;
    text-decoration: none;
    font-weight: 600;
    font-size: 14px;
}

.btn-primary {
    background: #2563eb;
    color: #fff;
}

.btn-success {
    background: #16a34a;
    color: #fff;
}

.btn-danger {
    background: #dc2626;
    color: #fff;
}

.btn-sm {
    background: #d97706;          /* ORANGE – FIXED */
    color: #ffffff;
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    transition: background 0.15s ease, transform 0.05s ease;
    line-height: 1;
    text-decoration: none;

}

.btn-sm:hover {
    background: #f59e0b;
}

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

.btn-sm:disabled {
    background: #7c4a03;
    cursor: not-allowed;
    opacity: 0.6;
}

/* CARD */
.dashboard-card {
    background: #0f141c;
    border-radius: 12px;
    border: 1px solid #30363d;
    padding: 20px;
    margin-top: 24px;
}

/* TABLE */
.table-wrapper {
    overflow-x: auto;
}

.trade-table {
    width: 100%;
    border-collapse: collapse;
}

.trade-table th,
.trade-table td {
    padding: 12px;
    border-bottom: 1px solid #e5e7eb;
    text-align: center;
    font-size: 13px;
    vertical-align: middle;
}

.trade-table th.actions,
.trade-table td.actions {
    width: 160px;              /* fixed column width */
    text-align: center;
    vertical-align: middle;
    white-space: nowrap;
}

/* Buttons spacing */
.trade-table td.actions .btn-sm {
    display: inline-block;
    margin: 0 4px;
}

.trade-table th {
    background: #f9fafb;
    font-weight: 700;
    color: #0e1117;
}

.muted {
    font-size: 12px;
    color: #6b7280;
}

/* TEXT COLORS */
.text-buy {
    color: #16a34a;
    font-weight: 700;
}

.text-sell {
    color: #dc2626;
    font-weight: 700;
}

.pnl-positive {
    color: #16a34a;
    font-weight: 700;
}

.pnl-negative {
    color: #dc2626;
    font-weight: 700;
}

/* LINKS */
.link {
    background: none;
    border: none;
    padding: 0;
    color: #2563eb;
    cursor: pointer;
    font-weight: 600;
}

/* MODAL */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: #fff;
    padding: 15px;
    border-radius: 8px;
    max-width: 90%;
    max-height: 90%;
}

.modal-content img {
    max-width: 100%;
    max-height: 80vh;
}

.modal-close {
    display: block;
    text-align: right;
    font-size: 22px;
    cursor: pointer;
    font-weight: bold;
}
/* ================================
   ACCOUNT DETAILS (DASHBOARD)
================================ */
.account-details {
    margin-top: 12px;
    margin-bottom: 20px;
    padding: 14px 18px;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;

    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 14px 24px;
}

.account-details .label {
    display: block;
    font-size: 12px;
    color: #6b7280;
    margin-bottom: 2px;
}

.account-details .value {
    font-size: 14px;
    font-weight: 600;
    color: #0e1117;
}

.account-details .value.pnl-positive {
    color: #16a34a; /* green */
}

.account-details .value.pnl-negative {
    color: #dc2626; /* red */
}

.account-details .value.pnl-neutral {
    color: #0e1117; /* dark neutral */
}
.pnl-positive { color: #16a34a !important; }
.pnl-negative { color: #dc2626 !important; }
/* ================================
   TRADE FILTERS
================================ */
.trade-filters {
    display: flex;
    flex-wrap: nowrap;
    gap: 10px;
    align-items: center;
    margin-bottom: 14px;
}

.trade-filters input,
.trade-filters select {
    height: 36px;
    padding: 6px 10px;
    min-width: 120px;
}

.trade-filters input[type="text"] {
    min-width: 160px;
}

/* ================================
   PAGINATION
================================ */
.pagination {
    margin-top: 16px;
    display: flex;
    gap: 6px;
}

.pagination a {
    padding: 6px 10px;
    border-radius: 6px;
    text-decoration: none;
    color: #fff;
    font-size: 14px;
}

.pagination a.active {
    background: #0e1117;
    color: #fff;
    border: 1px solid #d1d5db;
}
.empty-state {
    padding: 20px;
    color: #0e1117;
    font-size: 14px;
    text-align: center;
    border-color: #0e1117;
}

.rows-per-page {
    display: flex;
    align-items: center;
    gap: 6px;
    width: auto;
}

.rows-per-page label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.rows-per-page select {
    width: auto !important;
    min-width: 70px;
    max-width: 90px;
    padding: 4px 6px;
}

/* ================================
   SORT
================================ */
.trade-table th a {
    color: inherit;
    text-decoration: none;
    font-weight: 600;
}

.trade-table th a:hover {
    text-decoration: underline;
}
/* ==========================================================
   MODAL OVERLAY (ENHANCED LOOK)
   ========================================================== */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(8, 11, 20, 0.72);
    backdrop-filter: blur(6px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 100000;
}

/* ==========================================================
   MODAL CONTAINER (COMPACT & STYLISH)
   ========================================================== */

.modal {
    background: linear-gradient(180deg, #0f172a, #020617);
    border-radius: 14px;
    width: 100%;
    max-width: 360px;
    padding: 22px 24px 24px;

    box-shadow:
        0 30px 60px rgba(0, 0, 0, 0.85),
        inset 0 0 0 1px rgba(255, 255, 255, 0.05);

    animation: modalScaleIn 0.18s ease-out;
}

/* ==========================================================
   MODAL TEXT
   ========================================================== */

.modal h2 {
    margin-bottom: 14px;
    font-size: 17px;
    font-weight: 600;
    color: #e6edf3;
    text-align: center;
}

.modal label {
    display: block;
    margin: 12px 0 6px;
    font-size: 12px;
    color: #9da7b3;
}

/* ==========================================================
   INPUTS
   ========================================================== */

.modal input {
    width: 100%;
    padding: 9px 10px;
    font-size: 14px;
    border-radius: 8px;
    border: 1px solid #1f2933;
    background: #020617;
    color: #e6edf3;
}

.modal input:focus {
    outline: none;
    border-color: #2563eb;
}

/* ==========================================================
   BUTTON (INHERITS EXISTING BTN STYLES)
   ========================================================== */

.modal button {
    width: 100%;
    margin-top: 18px;
    padding: 10px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
}

/* ==========================================================
   ANIMATION
   ========================================================== */

@keyframes modalScaleIn {
    from {
        opacity: 0;
        transform: scale(0.94);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}
/* ==========================================================
   FIX MODAL LAYOUT & ALIGNMENT
   ========================================================== */

/* Ensure modal sizes to content, not screen */
.modal {
    height: auto;
    min-height: unset;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

/* Keep form elements stacked cleanly */
.modal label,
.modal input,
.modal button {
    width: 100%;
}

/* Prevent weird left-shifted content */
.modal > * {
    box-sizing: border-box;
}

/* Improve spacing rhythm */
.modal label {
    margin-top: 10px;
}

.modal input {
    margin-bottom: 4px;
}

/* Button alignment fix */
.modal button {
    margin-top: 20px;
    align-self: stretch;
}
/* ================================
   IMAGE VIEWER MODAL (ISOLATED)
================================ */

.image-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.9);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 200000;
}

.image-modal {
    position: relative;
    max-width: 95vw;
    max-height: 95vh;
}

.image-modal img {
    display: block;
    max-width: 100%;
    max-height: 95vh;
    object-fit: contain;
}

/* Close (X) */
.image-modal-close {
    position: absolute;
    top: -10px;
    right: -10px;
    width: 36px;
    height: 36px;
    background: #000;
    color: #fff;
    border-radius: 50%;
    font-size: 22px;
    line-height: 36px;
    text-align: center;
    cursor: pointer;
}
/* ===============================
   LIVE TRADES CARD
=============================== */

#live-trades-card {
    background: #ffffff;
    border-radius: 14px;
    padding: 18px 20px;
    box-shadow: 0 6px 18px rgba(0,0,0,0.06);
}

#live-trades-card h3 {
    margin: 0 0 14px 0;
    font-size: 18px;
    font-weight: 600;
    color: #111827;
    display: flex;
    align-items: center;
    gap: 8px;
}

#live-trades-card h3::before {
    content: "●";
    color: #22c55e; /* live green */
    font-size: 14px;
}

/* ===============================
   TABLE BASE
=============================== */

#live-trades-card table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

#live-trades-card thead th {
    text-align: left;
    font-weight: 600;
    color: #6b7280;
    padding: 10px 12px;
    border-bottom: 1px solid #e5e7eb;
    white-space: nowrap;
}

#live-trades-card tbody td {
    padding: 10px 12px;
    border-bottom: 1px solid #f1f5f9;
    color: #111827;
    white-space: nowrap;
}

#live-trades-card tbody tr:last-child td {
    border-bottom: none;
}

/* ===============================
   ROW HOVER
=============================== */

#live-trades-card tbody tr:hover {
    background: #f9fafb;
}

/* ===============================
   BUY / SELL BADGES
=============================== */

#live-trades-card td:nth-child(3) {
    font-weight: 600;
}

#live-trades-card td:nth-child(3)::before {
    content: "";
}

#live-trades-card td:nth-child(3):contains("BUY") {
    color: #16a34a;
}

#live-trades-card td:nth-child(3):contains("SELL") {
    color: #dc2626;
}

/* ===============================
   P/L STYLING
=============================== */

.text-success {
    color: #16a34a;
    font-weight: 600;
}

.text-danger {
    color: #dc2626;
    font-weight: 600;
}

/* subtle pulse on update */
@keyframes pnlFlashGreen {
    from { background-color: rgba(34,197,94,0.25); }
    to   { background-color: transparent; }
}

@keyframes pnlFlashRed {
    from { background-color: rgba(239,68,68,0.25); }
    to   { background-color: transparent; }
}

.pnl-updated-positive {
    animation: pnlFlashGreen 0.6s ease-out;
}

.pnl-updated-negative {
    animation: pnlFlashRed 0.6s ease-out;
}

/* ===============================
   MUTED / EMPTY STATE
=============================== */

#live-trades-card .muted {
    text-align: center;
    color: #9ca3af;
    font-style: italic;
    padding: 16px;
}

/* ===============================
   RESPONSIVE
=============================== */

@media (max-width: 900px) {
    #live-trades-card table {
        font-size: 13px;
    }

    #live-trades-card thead {
        display: none;
    }

    #live-trades-card tbody tr {
        display: block;
        margin-bottom: 12px;
        border: 1px solid #e5e7eb;
        border-radius: 10px;
        padding: 8px;
    }

    #live-trades-card tbody td {
        display: flex;
        justify-content: space-between;
        padding: 6px 10px;
        border-bottom: none;
    }

    #live-trades-card tbody td::before {
        content: attr(data-label);
        font-weight: 600;
        color: #6b7280;
    }
}