/* ==========================================================================
   Bullrun iPad Stock Exchange LED Matrix Terminal & DOS Writer CSS System
   ========================================================================== */

/* Google Fonts Import for LED Matrix & MONOSPACE TERMINALS */
@import url('https://fonts.googleapis.com/css2?family=Courier+Prime:ital,wght@0,400;0,700;1,400&family=DotGothic16&family=Orbitron:wght@500;700;900&family=Pixelify+Sans:wght@500;700&family=Press+Start+2P&family=Roboto+Mono:wght@400;600;700&family=Share+Tech+Mono&family=Silkscreen:wght@400;700&family=VT323&display=swap');

.bullrun-writer-wrapper {
    --bg-color: #060a12;
    --text-color: #38bdf8;
    --border-color: #1e293b;
    --header-bg: #0f172a;
    --cursor-color: #38bdf8;
    --selection-bg: rgba(56, 189, 248, 0.3);
    --glow-effect: 0 0 8px rgba(56, 189, 248, 0.4);
    --current-font-size: 11px;
    
    width: 100%;
    max-width: 1050px;
    margin: 0 auto;
    font-family: system-ui, -apple-system, sans-serif;
    box-sizing: border-box;
}

/* Color Theme 1: NYSE / Stock Exchange LED Board (Default Deep Navy) */
.bullrun-writer-wrapper.theme-dotmatrix {
    --bg-color: #030712;
    --text-color: #38bdf8;
    --border-color: #1e293b;
    --header-bg: #0f172a;
    --cursor-color: #38bdf8;
    --selection-bg: rgba(56, 189, 248, 0.3);
    --glow-effect: 0 0 10px rgba(56, 189, 248, 0.5);
}

/* Color Theme 2: Bloomberg Stock Exchange Terminal (Yellow/Amber on Dark) */
.bullrun-writer-wrapper.theme-stock {
    --bg-color: #05050a;
    --text-color: #f59e0b;
    --border-color: #27272a;
    --header-bg: #18181b;
    --cursor-color: #f59e0b;
    --selection-bg: rgba(245, 158, 11, 0.3);
    --glow-effect: 0 0 10px rgba(245, 158, 11, 0.5);
}

/* Color Theme 3: Phosphor Green CRT */
.bullrun-writer-wrapper.theme-green {
    --bg-color: #021206;
    --text-color: #00ff66;
    --border-color: #052e16;
    --header-bg: #04210e;
    --cursor-color: #00ff66;
    --selection-bg: rgba(0, 255, 102, 0.3);
    --glow-effect: 0 0 8px rgba(0, 255, 102, 0.4);
}

/* Color Theme 4: Phosphor Amber CRT */
.bullrun-writer-wrapper.theme-amber {
    --bg-color: #120902;
    --text-color: #ffb000;
    --border-color: #451a03;
    --header-bg: #291002;
    --cursor-color: #ffb000;
    --selection-bg: rgba(255, 176, 0, 0.3);
    --glow-effect: 0 0 8px rgba(255, 176, 0, 0.4);
}

/* Color Theme 5: VGA White Monochrome */
.bullrun-writer-wrapper.theme-white {
    --bg-color: #0a0a0a;
    --text-color: #f3f4f6;
    --border-color: #262626;
    --header-bg: #171717;
    --cursor-color: #ffffff;
    --selection-bg: rgba(255, 255, 255, 0.3);
    --glow-effect: 0 0 6px rgba(255, 255, 255, 0.3);
}

/* Color Theme 6: Cyber Cyan */
.bullrun-writer-wrapper.theme-cyber {
    --bg-color: #03131d;
    --text-color: #00f0ff;
    --border-color: #083344;
    --header-bg: #062837;
    --cursor-color: #00f0ff;
    --selection-bg: rgba(0, 240, 255, 0.3);
    --glow-effect: 0 0 10px rgba(0, 240, 255, 0.5);
}

/* Responsive Aspect Ratio Image Wrapper for BULL RUN new 2.png */
.bullrun-ipad-container {
    position: relative;
    width: 141.54%;
    padding-top: 74.12%; /* Matching 141.54% * 52.366% (2007x1051 aspect ratio) */
    background-image: var(--ipad-bg-image, url('../images/BULL RUN new 2.png'));
    background-size: contain;
    background-position: center;
    background-repeat: no-repeat;
    border-radius: 14px;
    overflow: visible;
    margin-left: -39.63%;
    transition: all 0.3s ease;
}

/* iPad Screen Overlay Positioning Bounds (Matching exact screen pixel region in BULL RUN new 2.png) */
.bullrun-dos-screen {
    position: absolute;
    top: 19.0%;
    left: 37.0%;
    width: 61.1%;
    height: 77.9%;
    background-color: var(--bg-color);
    border-radius: 4px 4px 34px 4px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: inset 0 0 15px rgba(0, 0, 0, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

/* CRT Scanline Overlay Effect */
.bullrun-crt-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        rgba(18, 16, 16, 0) 50%, 
        rgba(0, 0, 0, 0.25) 50%
    );
    background-size: 100% 4px;
    z-index: 10;
    pointer-events: none;
    opacity: 0.7;
}

.bullrun-dos-screen.no-scanlines .bullrun-crt-overlay {
    display: none;
}

/* Stock Exchange Live Ticker Tape Bar */
.bullrun-stock-ticker-bar {
    background: #020617;
    border-bottom: 1px solid #1e293b;
    padding: 5px 0;
    overflow: hidden;
    white-space: nowrap;
    z-index: 5;
    font-size: 16.5px;
    font-weight: 800;
    color: #fbbf24;
    letter-spacing: 0.5px;
}

.bullrun-ticker-track {
    display: inline-block;
    white-space: nowrap;
    padding-left: 100%;
    animation: marquee 22s linear infinite;
}

@keyframes marquee {
    0% { transform: translate3d(0, 0, 0); }
    100% { transform: translate3d(-100%, 0, 0); }
}

/* MS-DOS Header Bar */
.bullrun-dos-header {
    background-color: var(--header-bg);
    color: var(--text-color);
    padding: 6px 12px;
    font-size: 13.5px;
    font-family: 'DotGothic16', 'Courier Prime', monospace;
    font-weight: bold;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    user-select: none;
    z-index: 5;
}

/* MS-DOS Main Text Body */
.bullrun-dos-body {
    flex: 1;
    position: relative;
    padding: 4px 6px;
    display: flex;
    overflow: auto;
    z-index: 5;
}

/* Textarea - Guaranteed single line row formatting for 5-column table */
.bullrun-dos-editor {
    width: 100%;
    height: 100%;
    background: transparent;
    border: none;
    outline: none;
    resize: none;
    padding: 4px 2px;
    color: var(--text-color);
    font-family: 'DotGothic16', monospace;
    font-size: var(--current-font-size, 11px);
    line-height: 1.35;
    letter-spacing: -0.2px;
    white-space: pre !important; /* Never wrap 5-column lines onto a second row! */
    overflow-x: auto !important;
    overflow-y: auto !important;
    word-break: normal !important;
    word-wrap: normal !important;
    box-sizing: border-box;
    text-shadow: var(--glow-effect);
    scrollbar-width: thin;
    scrollbar-color: rgba(56, 189, 248, 0.2) transparent;
}

.bullrun-dos-editor::-webkit-scrollbar {
    width: 4px;
    height: 4px;
}

.bullrun-dos-editor::-webkit-scrollbar-track {
    background: transparent;
}

.bullrun-dos-editor::-webkit-scrollbar-thumb {
    background: rgba(56, 189, 248, 0.25);
    border-radius: 2px;
}

.bullrun-dos-editor::-webkit-scrollbar-thumb:hover {
    background: rgba(56, 189, 248, 0.5);
}

.bullrun-dos-editor::selection {
    background-color: var(--selection-bg);
    color: var(--text-color);
}

/* MS-DOS Footer Status Bar */
.bullrun-dos-footer {
    background-color: var(--header-bg);
    color: var(--text-color);
    padding: 5px 14px 5px 12px;
    font-size: 14px;
    font-family: 'DotGothic16', 'Courier Prime', monospace;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid var(--border-color);
    border-bottom-right-radius: 34px;
    user-select: none;
    z-index: 5;
}

.save-badge {
    background: #10b981;
    color: #000;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 13.5px;
    font-weight: 800;
    display: inline-block;
}

/* Multi-Page Indicator & Controls */
.dos-page-indicator {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(15, 23, 42, 0.85);
    border: 1px solid var(--border-color);
    padding: 3px 10px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 800;
    color: var(--text-color);
    user-select: none;
}

.dos-page-indicator .btn-page-nav {
    cursor: pointer;
    padding: 0 6px;
    font-size: 14px;
    font-weight: bold;
    color: var(--text-color);
    transition: transform 0.12s, color 0.12s;
}

.dos-page-indicator .btn-page-nav:hover {
    color: #38bdf8;
    transform: scale(1.25);
}

.dos-page-indicator .page-label {
    min-width: 80px;
    text-align: center;
    letter-spacing: 0.5px;
    font-size: 14px;
    font-weight: 800;
}

/* Analysis Button in Terminal Footer */
.dos-btn-analyse {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: rgba(2, 132, 199, 0.25);
    border: 1px solid var(--border-color);
    color: var(--text-color);
    font-family: inherit;
    font-size: 13.5px;
    font-weight: 800;
    padding: 3px 10px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s ease;
    user-select: none;
    line-height: 1.3;
    outline: none;
}

.dos-btn-analyse:hover {
    background: #0284c7;
    color: #ffffff;
    border-color: #38bdf8;
    box-shadow: 0 0 10px rgba(56, 189, 248, 0.6);
    transform: translateY(-1px);
}

.dos-btn-analyse.active-analyse {
    background: #f59e0b;
    border-color: #d97706;
    color: #000000;
    box-shadow: 0 0 10px rgba(245, 158, 11, 0.6);
}

/* Font Resizer Buttons (A- / 100% / A+) in Terminal Footer */
.btn-font-dec, .btn-font-reset, .btn-font-inc {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--border-color);
    color: var(--text-color);
    font-family: inherit;
    font-size: 13.5px;
    font-weight: 800;
    padding: 3px 8px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s ease;
    user-select: none;
    line-height: 1.3;
    outline: none;
}

.btn-font-reset {
    background: rgba(56, 189, 248, 0.16);
    border-color: rgba(56, 189, 248, 0.45);
    color: #38bdf8;
    padding: 3px 7px;
    font-size: 12.5px;
    font-weight: 800;
    letter-spacing: 0.5px;
}

.btn-font-dec:hover, .btn-font-reset:hover, .btn-font-inc:hover {
    background: rgba(56, 189, 248, 0.35);
    color: #ffffff;
    border-color: #38bdf8;
    box-shadow: 0 0 8px rgba(56, 189, 248, 0.5);
    transform: translateY(-1px);
}

.btn-font-dec:active, .btn-font-reset:active, .btn-font-inc:active {
    transform: translateY(0);
}

/* Telegram Bot Launch Button in Terminal Footer */
.dos-btn-tg-bot {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: rgba(0, 136, 204, 0.22);
    border: 1px solid #0088cc;
    color: #38bdf8;
    font-family: inherit;
    font-size: 13.5px;
    font-weight: 800;
    padding: 3px 10px;
    border-radius: 6px;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.15s ease;
    user-select: none;
    line-height: 1.3;
    outline: none;
    box-shadow: 0 0 6px rgba(0, 136, 204, 0.35);
}

.dos-btn-tg-bot:hover {
    background: #0088cc;
    color: #ffffff;
    border-color: #38bdf8;
    box-shadow: 0 0 12px rgba(56, 189, 248, 0.7);
    transform: translateY(-1px);
    text-decoration: none;
}

.dos-btn-tg-bot:active {
    transform: translateY(0);
    box-shadow: 0 0 4px rgba(56, 189, 248, 0.5);
}

.dos-clock {
    font-size: 13.5px;
    font-weight: 700;
    letter-spacing: 0.5px;
}

/* Floating Retro Page Badge inside Terminal Body */
.bullrun-floating-page-badge {
    position: absolute;
    top: 6px;
    right: 8px;
    background: rgba(15, 23, 42, 0.88);
    border: 1px solid var(--border-color);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 10px;
    font-family: 'DotGothic16', monospace;
    color: var(--text-color);
    z-index: 12;
    display: none;
    align-items: center;
    gap: 6px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.6);
    user-select: none;
}

.bullrun-floating-page-badge .btn-page-nav {
    cursor: pointer;
    padding: 0 4px;
    font-weight: bold;
    transition: transform 0.12s, color 0.12s;
}

.bullrun-floating-page-badge .btn-page-nav:hover {
    color: #38bdf8;
    transform: scale(1.25);
}

.bullrun-floating-page-badge .page-badge-text {
    min-width: 66px;
    text-align: center;
    letter-spacing: 0.5px;
}

/* Interactive Control Toolbar Below iPad */
.bullrun-toolbar {
    display: none !important;
}

.bullrun-btn {
    background: #1e293b;
    color: #f8fafc;
    border: 1px solid #334155;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.bullrun-btn:hover {
    background: #334155;
    border-color: #475569;
    color: #38bdf8;
}

.bullrun-btn.active {
    background: #0284c7;
    border-color: #38bdf8;
    color: #ffffff;
}

.bullrun-btn-danger {
    background: #7f1d1d;
    border-color: #991b1b;
    color: #fca5a5;
}

.bullrun-btn-danger:hover {
    background: #991b1b;
    color: #ffffff;
}

.bullrun-select {
    background: #1e293b;
    color: #f8fafc;
    border: 1px solid #334155;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
}

/* Fullscreen Mode Override */
.bullrun-writer-wrapper.fullscreen {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    max-width: none !important;
    z-index: 999999 !important;
    background: #000000 !important;
    padding: 0 !important;
    margin: 0 !important;
}

.bullrun-writer-wrapper.fullscreen .bullrun-ipad-container {
    padding-top: 0 !important;
    height: calc(100vh - 55px) !important;
    border-radius: 0 !important;
}

.bullrun-writer-wrapper.fullscreen .bullrun-dos-screen {
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    border-radius: 0 !important;
}

.bullrun-toast {
    position: absolute;
    top: 12px;
    right: 14px;
    background: #10b981;
    color: #000;
    padding: 3px 10px;
    border-radius: 4px;
    font-weight: bold;
    font-size: 11px;
    opacity: 0;
    transition: opacity 0.25s ease;
    pointer-events: none;
    z-index: 25;
    box-shadow: 0 2px 10px rgba(0,0,0,0.5);
}

.bullrun-toast.show {
    opacity: 1;
}

/* ==========================================================================
   Mobile & Tablet Responsive System (Screen width <= 768px & <= 480px)
   ========================================================================== */
@media (max-width: 768px) {
    .bullrun-writer-wrapper {
        max-width: 100% !important;
        padding: 0 4px !important;
        margin: 0 auto 16px auto !important;
    }

    /* Transform landscape iPad with bull background into a standalone mobile terminal */
    .bullrun-writer-wrapper .bullrun-ipad-container {
        width: 100% !important;
        margin-left: 0 !important;
        padding-top: 0 !important;
        height: auto !important;
        min-height: 520px !important;
        background-image: none !important; /* Hide distorted landscape mockup on mobile */
        background: #030712 !important;
        border: 2px solid #1e293b !important;
        border-radius: 16px !important;
        box-shadow: 0 10px 35px rgba(0, 0, 0, 0.7), inset 0 0 25px rgba(0, 0, 0, 0.8) !important;
        overflow: hidden !important;
        display: flex !important;
        flex-direction: column !important;
    }

    .bullrun-writer-wrapper .bullrun-dos-screen {
        position: relative !important;
        top: 0 !important;
        left: 0 !important;
        width: 100% !important;
        height: 520px !important;
        border-radius: 14px !important;
        border: none !important;
        box-shadow: none !important;
        display: flex !important;
        flex-direction: column !important;
    }

    .bullrun-writer-wrapper .bullrun-stock-ticker-bar {
        font-size: 13px !important;
        padding: 6px 0 !important;
    }

    .bullrun-writer-wrapper .bullrun-dos-header {
        padding: 8px 12px !important;
        font-size: 12px !important;
        gap: 6px !important;
    }

    .bullrun-writer-wrapper .bullrun-dos-body {
        flex: 1 1 auto !important;
        overflow-x: auto !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
        padding: 6px !important;
    }

    .bullrun-writer-wrapper .bullrun-dos-editor {
        padding: 8px !important;
        font-size: 11px !important;
        overflow-x: auto !important;
        white-space: pre !important;
        -webkit-overflow-scrolling: touch !important;
    }

    .bullrun-writer-wrapper .bullrun-dos-footer {
        display: flex !important;
        flex-wrap: wrap !important;
        gap: 6px !important;
        padding: 8px 10px !important;
        font-size: 11px !important;
        justify-content: center !important;
        height: auto !important;
        min-height: 42px !important;
        border-top: 1px solid #1e293b !important;
        border-bottom-right-radius: 0 !important;
    }

    .bullrun-writer-wrapper .bullrun-dos-footer .dos-status-item {
        font-size: 11.5px !important;
        padding: 4px 8px !important;
        white-space: nowrap !important;
    }

    .bullrun-writer-wrapper .save-badge {
        white-space: nowrap !important;
        font-size: 11.5px !important;
        padding: 3px 6px !important;
    }
}

@media (max-width: 480px) {
    .bullrun-writer-wrapper .bullrun-ipad-container {
        min-height: 480px !important;
    }

    .bullrun-writer-wrapper .bullrun-dos-screen {
        height: 480px !important;
    }

    .bullrun-writer-wrapper .bullrun-dos-header {
        flex-direction: column !important;
        gap: 4px !important;
        align-items: flex-start !important;
        padding: 6px 10px !important;
    }

    .bullrun-writer-wrapper .bullrun-dos-footer {
        padding: 6px 6px !important;
        gap: 4px !important;
    }

    .bullrun-writer-wrapper .bullrun-dos-footer .dos-status-item {
        font-size: 10.5px !important;
        padding: 3px 6px !important;
    }
}

