/* Zerodha Console F&O P&L Responsive Stylesheet */

:root {
    --zerodha-bg: #fcfdfd;
    --zerodha-text-dark: #3e4b5b;
    --zerodha-text-grey: #9ba6b2;
    --zerodha-border: #eef2f5;
    
    /* Exact green color provided by the user (#22A58D) */
    --zerodha-green: #22A58D; 
    --zerodha-red: #B97B67; /* Terracotta custom loss color */
    --zerodha-teal: #00b093; /* Authentic Zerodha Done Teal */
}

/* Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: #f2f4f6; /* Modern desktop workspace background */
    color: var(--zerodha-text-dark);
    overflow: hidden;
    height: 100vh;
    width: 100vw;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Full-Screen Canvas (No phone bezel, responsive viewports) */
.app-container {
    display: block;
    width: 100vw;
    height: 100vh;
    margin: 0;
    padding: 0;
    overflow: hidden;
}

.preview-pane {
    width: 100%;
    height: 100%;
    padding: 0;
}

/* Simulator screen - Fills entire viewport */
.phone-mockup {
    width: 100%;
    height: 100vh;
    background-color: var(--zerodha-bg);
    color: var(--zerodha-text-dark);
    border-radius: 0;
    overflow: hidden;
    position: relative;
    display: flex;
    flex-direction: column;
    user-select: text;
    box-shadow: none;
}

/* Premium Desktop Mobile Frame Mockup (Widescreen screens) */
@media (min-width: 768px) {
    .app-container {
        width: 100%;
        max-width: 440px; /* Elegant phone ratio width */
        height: 95vh;
        max-height: 880px;
        margin: auto;
        border-radius: 40px; /* High-fidelity curved device edges */
        box-shadow: 0 25px 60px rgba(0, 0, 0, 0.16); /* Luxurious floating shadow */
        border: 10px solid #1a1a1c; /* Premium physical dark phone bezel */
        background-color: var(--zerodha-bg);
        position: relative;
    }
    
    .phone-mockup {
        height: 100%;
    }
}

/* =========================================
   MOBILE / APK LAYOUT STYLES (DEFAULT < 768px)
   ========================================= */

/* System Top Status Bar */
.status-bar {
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    font-size: 11.5px;
    font-weight: 500; /* Flattened weight, not bold! */
    color: #000000;
    letter-spacing: 0.02em;
    background-color: var(--zerodha-bg);
    z-index: 10;
    cursor: pointer;
}

.status-bar-left {
    display: flex;
    align-items: center;
}

.status-bar-right {
    display: flex;
    align-items: center;
    gap: 6px;
}

.status-bar-icons {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 9.5px;
    font-weight: 500; /* Flattened weight, not bold! */
}

.battery-percent {
    margin-right: 1px;
}

.battery-icon {
    width: 17px;
    height: 10px;
    border: 1px solid #000;
    border-radius: 2px;
    padding: 1px;
    display: flex;
    align-items: center;
    position: relative;
}

.battery-icon::after {
    content: '';
    position: absolute;
    right: -2px;
    top: 2.5px;
    width: 1.5px;
    height: 4px;
    background-color: #000;
    border-top-right-radius: 1px;
    border-bottom-right-radius: 1px;
}

.battery-level {
    height: 100%;
    background-color: #000;
    border-radius: 0.5px;
}

/* Navigation Header */
.phone-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    background-color: var(--zerodha-bg);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 18px;
}

.back-btn {
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
}

.title-wrap {
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.title-wrap h3 {
    font-size: 15.5px; /* Compacted header size as requested */
    font-weight: 500; /* Flattened weight, not bold! */
    color: #1a1a1a;
    line-height: 1.25;
}

.subtitle {
    font-size: 12px; /* Scaled up 15% */
    color: var(--zerodha-text-grey);
    font-weight: 500;
    margin-top: 1px;
}

.download-link {
    font-size: 14px; /* Scaled up 15% */
    font-weight: 500; /* Flattened weight, not bold! */
    color: var(--zerodha-teal);
    text-decoration: none;
    cursor: pointer;
    padding: 6px 10px;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.download-link:hover {
    background-color: rgba(0, 176, 147, 0.05);
}

/* Date Selection Pill (LEFT ALIGNED) */
.date-pill-wrap {
    display: flex;
    justify-content: flex-start;
    padding-left: 20px;
    margin: 8px 0 18px;
}

.date-pill {
    background-color: #f5f6f8;
    border-radius: 50px;
    padding: 10px 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13.8px; /* Scaled up 15% */
    color: #222222;
    font-weight: 500; /* Flattened weight, not bold! */
    cursor: pointer;
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.02);
    border: 1px solid rgba(0, 0, 0, 0.01);
    transition: background-color 0.2s;
}

.date-pill:hover {
    background-color: #ebecef;
}

.calendar-icon {
    display: flex;
    align-items: center;
}

/* Realised P&L Summary Card (Vertical flex stack on Mobile) */
.summary-card-wrap {
    padding: 0 20px;
    margin-bottom: 24px;
}

.summary-card {
    background-color: #ffffff;
    border: 1px solid var(--zerodha-border);
    border-radius: 16px;
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    box-shadow: 0 2px 10px rgba(62, 75, 91, 0.03);
}

.summary-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 15.2px; /* Scaled up 15% */
    color: #333333;
    width: 100%;
}

.summary-label {
    font-weight: 500;
    color: #4a545e;
}

.summary-label.bold {
    font-weight: 500; /* Flattened weight, not bold! */
    color: #2c333a;
}

.summary-val {
    font-weight: 500; /* Flattened weight, not bold! */
    color: #2c333a;
}

.summary-val.bold {
    font-weight: 500; /* Flattened weight, not bold! */
    font-size: 17.5px; /* Scaled up 15% */
}

.summary-val.green {
    color: var(--zerodha-green) !important;
    text-shadow: 
        0 0 6px rgba(34, 165, 141, 0.45),
        0 0 12px rgba(34, 165, 141, 0.25);
}

.summary-val.red {
    color: var(--zerodha-red) !important;
    text-shadow: 
        0 0 6px rgba(185, 123, 103, 0.45),
        0 0 12px rgba(185, 123, 103, 0.25);
}

.summary-divider {
    height: 1px;
    background-color: #eef2f5;
    margin: 2px 0;
    width: 100%;
}

/* Table Headers */
.contracts-header {
    display: flex;
    justify-content: space-between;
    padding: 0 24px 12px;
    border-bottom: 1px solid var(--zerodha-border);
    font-size: 12.8px; /* Scaled up 15% */
    font-weight: 500; /* Flattened weight, not bold! */
    color: var(--zerodha-text-grey);
    text-transform: capitalize;
}

.col-header-name {
    flex-grow: 1;
}

.col-header-pnl {
    text-align: right;
}

/* Contracts List Container */
.contracts-list {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    overflow-y: auto;
}

/* Contract Row */
.contract-row {
    display: flex;
    justify-content: space-between;
    padding: 18px 24px;
    border-bottom: 1px solid var(--zerodha-border);
    position: relative;
    transition: background-color 0.2s;
    cursor: pointer;
}

.contract-left {
    display: flex;
    flex-direction: column;
    gap: 5px;
    flex-grow: 1;
    padding-right: 15px;
}

.contract-name {
    font-size: 14.8px; /* Scaled up 15% */
    font-weight: 500; /* Flattened weight, not bold! */
    color: #333333;
    line-height: 1.35;
    word-break: break-word;
}

.contract-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 5px;
    min-width: 110px;
}

.contract-pnl {
    font-size: 15.5px; /* Scaled up 15% */
    font-weight: 500; /* Flattened weight, not bold! */
}

.contract-pnl.green {
    color: var(--zerodha-green);
    text-shadow: 0 0 4px rgba(34, 165, 141, 0.35);
}

.contract-pnl.red {
    color: var(--zerodha-red);
    text-shadow: 
        0 0 6px rgba(185, 123, 103, 0.45),
        0 0 12px rgba(185, 123, 103, 0.25);
}

.contract-qty {
    font-size: 12.8px; /* Scaled up 15% */
    color: var(--zerodha-text-grey);
    font-weight: 500;
}

.contract-row:hover {
    background-color: rgba(0, 176, 147, 0.02);
}

/* Focus styles for inline editing */
.phone-mockup [contenteditable="true"] {
    outline: none;
    border-radius: 3px;
    transition: background-color 0.2s, box-shadow 0.2s;
}

.phone-mockup [contenteditable="true"]:focus {
    background-color: rgba(0, 176, 147, 0.08);
    box-shadow: 0 0 0 2px rgba(0, 176, 147, 0.2);
}

/* EXPORT PREPARATION (Hides UI elements when capturing) */
.phone-mockup.exporting {
    border-radius: 0 !important;
}

.phone-mockup.exporting [contenteditable="true"]:hover {
    background-color: transparent !important;
}

/* Hide helper utilities */
.show-on-desktop {
    display: none !important;
}

/* =========================================
   BOTTOM-SHEETS & MODAL OVERLAYS
   ========================================= */

.modal-backdrop {
    position: absolute; /* Constrained relative to phone-mockup parent */
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(2px);
    display: flex;
    align-items: center; /* Centered vertically */
    justify-content: center; /* Centered horizontally */
    z-index: 100;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
    border-radius: inherit; /* Fits inside device curved bezel */
}

.modal-backdrop.show {
    opacity: 1;
    pointer-events: auto;
}

/* Centered Dialog Box Form Modals */
.bottom-sheet {
    width: 90%; /* Balanced margin space on left and right */
    max-width: 380px; /* Bounded nicely inside bezel */
    background-color: #ffffff;
    border-radius: 20px; /* Fully rounded card corners on all 4 sides */
    padding: 22px 18px 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin: 0; /* Positioned by flex centering */
    transform: scale(0.92); /* Bouncy pop zoom-in transition */
    opacity: 0;
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.25s ease;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.30);
    color: #222222;
    max-height: calc(100% - 32px); /* Balanced margin space on top and bottom */
    overflow-y: auto; /* Scrollable if content exceeds bounds */
    scrollbar-width: none; /* Hide scrollbars on Firefox */
}

.bottom-sheet::-webkit-scrollbar {
    display: none; /* Hide scrollbars on Chrome, Safari, Opera */
}

.modal-backdrop.show .bottom-sheet {
    transform: scale(1);
    opacity: 1;
}

/* Drag bar indicator at top */
.sheet-handle {
    width: 38px;
    height: 4px;
    background-color: #e2e8f0;
    border-radius: 10px;
    align-self: center;
    margin-bottom: 4px;
}

.sheet-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.sheet-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: #222222;
}

.sheet-close-btn {
    font-size: 22px;
    font-weight: 600;
    color: #94a3b8;
    background: none;
    border: none;
    cursor: pointer;
}

/* Radio buttons matching the photo exactly */
.radio-list {
    display: flex;
    flex-direction: column;
}

.radio-option {
    display: flex;
    align-items: center;
    gap: 14px;
    cursor: pointer;
    padding: 14px 4px;
    border-bottom: 1px solid #f1f3f6;
    font-size: 0.94rem;
    font-weight: 500;
    color: #333333;
    user-select: none;
}

.radio-option:last-child {
    border-bottom: none;
}

.radio-option input[type="radio"] {
    appearance: none;
    -webkit-appearance: none;
    width: 22px;
    height: 22px;
    border: 2px solid #cbd5e1;
    border-radius: 50%;
    outline: none;
    display: grid;
    place-content: center;
    transition: border-color 0.2s, background-color 0.2s;
    cursor: pointer;
    background-color: #fff;
}

.radio-option input[type="radio"]:checked {
    border-color: var(--zerodha-teal);
}

.radio-option input[type="radio"]::before {
    content: "";
    width: 11px;
    height: 11px;
    border-radius: 50%;
    transform: scale(0);
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
    background-color: var(--zerodha-teal);
}

.radio-option input[type="radio"]:checked::before {
    transform: scale(1);
}

/* Custom Date Range Inputs Box */
.custom-date-container {
    display: flex;
    gap: 14px;
    margin-top: 10px;
    width: 100%;
}

.date-box-wrap {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
}

.date-box-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: #64748b;
}

.date-input-field {
    position: relative;
    display: flex;
    align-items: center;
    background-color: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 10px 14px;
    transition: border-color 0.2s;
}

.date-input-field:focus-within {
    border-color: var(--zerodha-teal);
}

.date-input-field input {
    border: none;
    background: transparent;
    font-size: 0.95rem;
    font-weight: 600;
    color: #222;
    width: 100%;
    outline: none;
    cursor: pointer;
}

.date-input-field svg {
    color: #94a3b8;
    margin-left: 8px;
    flex-shrink: 0;
    pointer-events: none;
}

/* Done Button */
.btn-done {
    width: 100%;
    padding: 14px;
    background-color: var(--zerodha-teal);
    color: #ffffff;
    font-weight: 700;
    border: none;
    border-radius: 12px;
    font-size: 0.98rem;
    cursor: pointer;
    text-align: center;
    box-shadow: 0 4px 14px rgba(0, 176, 147, 0.25);
    transition: background-color 0.2s, transform 0.1s;
    margin-top: 8px;
}

.btn-done:hover {
    background-color: #009c82;
}

.btn-done:active {
    transform: scale(0.99);
}

/* =========================================
   TRADE MANAGER FORM
   ========================================= */

.form-group-sheet {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group-sheet label {
    font-size: 0.8rem;
    font-weight: 600;
    color: #64748b;
}

.form-group-sheet input,
.form-group-sheet select {
    background-color: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 11px 14px;
    color: #222;
    font-size: 0.92rem;
    font-weight: 600;
    outline: none;
    width: 100%;
    transition: border-color 0.2s;
}

.form-group-sheet input:focus,
.form-group-sheet select:focus {
    border-color: var(--zerodha-teal);
}

.form-row-sheet {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

.btn-group-row {
    display: flex;
    gap: 12px;
    margin-top: 8px;
}

.btn-danger-sheet {
    flex: 1;
    padding: 14px;
    background-color: rgba(239, 68, 68, 0.1);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.2);
    font-weight: 700;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-danger-sheet:hover {
    background-color: #ef4444;
    color: #ffffff;
}

/* CE/PE active toggler */
.option-type-toggle {
    display: flex;
    background-color: #f1f3f6;
    border-radius: 10px;
    padding: 4px;
    gap: 4px;
}

.option-type-btn {
    flex: 1;
    border: none;
    background: none;
    padding: 8px;
    font-weight: 700;
    font-size: 0.88rem;
    border-radius: 7px;
    color: #64748b;
    cursor: pointer;
    transition: all 0.2s;
}

.option-type-btn.active {
    background-color: #ffffff;
    color: #222222;
    box-shadow: 0 2px 6px rgba(0,0,0,0.06);
}

/* Secondary configurations triggers inside Settings Sheet */
.settings-utility-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-top: 14px;
    border-top: 1px solid #f1f3f6;
    padding-top: 18px;
}

.settings-util-btn {
    padding: 11px;
    border-radius: 8px;
    font-size: 0.84rem;
    font-weight: 700;
    cursor: pointer;
    border: 1px solid #e2e8f0;
    background-color: #f8fafc;
    color: #334155;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.settings-util-btn:hover {
    background-color: #e2e8f0;
    color: #0f172a;
}

.settings-util-btn-primary {
    grid-column: span 2;
    background-color: #0284c7;
    border-color: #0ea5e9;
    color: #ffffff;
    font-size: 0.92rem;
    padding: 13px;
}

.settings-util-btn-primary:hover {
    background-color: #0ea5e9;
    border-color: #38bdf8;
    color: #ffffff;
}

/* Export styles to hide backdrops */
.hide-on-export {
    transition: opacity 0.1s;
}

.exporting-mode .hide-on-export {
    display: none !important;
    opacity: 0 !important;
}

/* Webkit custom indicators */
input[type="date"]::-webkit-calendar-picker-indicator {
    background: transparent;
    bottom: 0;
    color: transparent;
    cursor: pointer;
    height: auto;
    left: 0;
    position: absolute;
    right: 0;
    top: 0;
    width: auto;
}
