/* ===================================
   TRADINGVIEW CHART MODAL - MOBILE RESPONSIVE
   =================================== */

/* Base Modal Styles */
.tradingview-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    overflow: hidden;
}

.tradingview-modal-content {
    background: #1e1e1e;
    width: 95%;
    max-width: 1400px;
    height: 90vh;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 10px 50px rgba(0, 0, 0, 0.5);
}

/* Header */
.chart-modal-header {
    background: #252525;
    padding: 15px 20px;
    border-bottom: 1px solid #333;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.chart-title h3 {
    margin: 0;
    font-size: 1.2rem;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 8px;
}

.chart-subtitle {
    font-size: 0.85rem;
    color: #888;
    margin-top: 4px;
}

.coin-info-badge {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

.coin-info-badge .badge {
    padding: 4px 10px;
    background: #333;
    border-radius: 4px;
    font-size: 0.75rem;
    color: #26a69a;
}

.chart-header-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.interval-selector {
    display: flex;
    align-items: center;
    gap: 8px;
}

.interval-label {
    font-size: 0.9rem;
    color: #888;
}

.interval-select {
    padding: 8px 12px;
    background: #333;
    color: #fff;
    border: 1px solid #444;
    border-radius: 6px;
    font-size: 0.9rem;
    cursor: pointer;
}

.chart-action-buttons {
    display: flex;
    gap: 8px;
}

.btn-chart-action,
.btn-chart-primary,
.btn-chart-close {
    padding: 8px 12px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.2s;
}

.btn-chart-action {
    background: #333;
    color: #fff;
}

.btn-chart-action:hover {
    background: #444;
    transform: scale(1.05);
}

.btn-chart-primary {
    background: #26a69a;
    color: #fff;
    font-weight: 500;
}

.btn-chart-primary:hover {
    background: #2bbbad;
}

.btn-chart-close {
    background: #ef5350;
    color: #fff;
}

.btn-chart-close:hover {
    background: #f44336;
}

/* Mobile Menu Toggle (Hidden on Desktop) */
.chart-mobile-menu-toggle {
    display: none;
    padding: 10px 16px;
    background: #26a69a;
    color: #fff;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    align-items: center;
    gap: 8px;
}

.chart-mobile-menu-toggle .menu-icon {
    font-size: 1.2rem;
}

/* Modal Body */
.chart-modal-body {
    display: flex;
    flex: 1;
    overflow: hidden;
    position: relative;
}

.chart-widget-container {
    flex: 1;
    position: relative;
    background: #1e1e1e;
    min-height: 400px;
}

#tradingview-widget-container {
    width: 100%;
    height: 100%;
}

.chart-loading {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #1e1e1e;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.chart-loading .spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #333;
    border-top-color: #26a69a;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.chart-loading p {
    margin-top: 15px;
    color: #888;
}

/* Sidebar */
.chart-sidebar {
    width: 300px;
    background: #252525;
    border-left: 1px solid #333;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding: 20px;
}

.sidebar-close-btn {
    display: none;
}

.indicator-selector h4,
.quick-actions h4 {
    margin: 0 0 15px 0;
    font-size: 1rem;
    color: #fff;
}

.indicator-tabs {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin-bottom: 15px;
}

.indicator-tab {
    padding: 10px;
    background: #333;
    color: #fff;
    border: 1px solid #444;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s;
}

.indicator-tab:hover {
    background: #3a3a3a;
}

.indicator-tab.active {
    background: #26a69a;
    border-color: #26a69a;
}

.indicator-settings {
    background: #2a2a2a;
    padding: 15px;
    border-radius: 6px;
}

.setting-group {
    margin-bottom: 15px;
}

.setting-group label {
    display: block;
    margin-bottom: 5px;
    font-size: 0.85rem;
    color: #aaa;
}

.setting-select,
.setting-input {
    width: 100%;
    padding: 8px;
    background: #333;
    color: #fff;
    border: 1px solid #444;
    border-radius: 4px;
}

.btn-apply-settings {
    width: 100%;
    padding: 10px;
    background: #26a69a;
    color: #fff;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    margin-top: 10px;
}

.btn-apply-settings:hover {
    background: #2bbbad;
}

.btn-quick-action {
    width: 100%;
    padding: 12px;
    background: #333;
    color: #fff;
    border: 1px solid #444;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    margin-bottom: 10px;
    text-align: left;
    transition: all 0.2s;
}

.btn-quick-action:hover {
    background: #3a3a3a;
    border-color: #26a69a;
}

/* Footer */
.chart-modal-footer {
    background: #252525;
    border-top: 1px solid #333;
    padding: 15px 20px;
    max-height: 200px;
    overflow-y: auto;
}

.footer-toggle-btn {
    display: none; /* Hidden on desktop */
    width: 100%;
    padding: 8px;
    background: transparent;
    color: #26a69a;
    border: none;
    cursor: pointer;
    font-size: 0.85rem;
    text-align: center;
    margin-bottom: 10px;
}

.indicator-info,
.market-info {
    margin-bottom: 15px;
}

.indicator-stats-grid,
.market-info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
}

.stat-card,
.market-card {
    background: #2a2a2a;
    padding: 12px;
    border-radius: 6px;
}

.stat-label,
.market-label {
    font-size: 0.75rem;
    color: #888;
    margin-bottom: 5px;
}

.stat-value,
.market-value {
    font-size: 1.1rem;
    font-weight: 600;
    color: #fff;
    margin-bottom: 3px;
}

.stat-desc,
.market-change,
.market-range,
.market-rank,
.market-trend {
    font-size: 0.75rem;
    color: #aaa;
}

/* Status Colors */
.bullish { color: #26a69a !important; }
.bearish { color: #ef5350 !important; }
.neutral { color: #888 !important; }
.overbought { color: #ff9800 !important; }
.oversold { color: #2196f3 !important; }
.positive { color: #26a69a !important; }
.negative { color: #ef5350 !important; }
.high { color: #ff5722 !important; }
.medium { color: #ff9800 !important; }
.low { color: #2196f3 !important; }
.strong { color: #4caf50 !important; }
.weak { color: #ff5722 !important; }

/* Toast Notifications */
.chart-toast {
    position: fixed;
    bottom: 30px;
    right: 30px;
    padding: 15px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 10001;
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.chart-toast.fade-out {
    animation: slideOut 0.3s ease-out;
}

@keyframes slideOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(400px);
        opacity: 0;
    }
}

.chart-toast-success { background: #26a69a; color: #fff; }
.chart-toast-error { background: #ef5350; color: #fff; }
.chart-toast-warning { background: #ff9800; color: #fff; }
.chart-toast-info { background: #2196f3; color: #fff; }

.toast-content {
    display: flex;
    align-items: center;
    gap: 10px;
}

.toast-icon {
    font-size: 1.2rem;
}

/* ===================================
   MOBILE RESPONSIVE STYLES
   =================================== */

@media (max-width: 768px) {
    /* Modal takes full screen on mobile */
    .tradingview-modal-overlay {
        padding: 0;
    }
    
    .tradingview-modal-content {
        width: 100%;
        height: 100vh;
        max-width: 100%;
        border-radius: 0;
    }
    
    /* Header adjustments */
    .chart-modal-header {
        padding: 12px 15px;
        flex-direction: column;
        align-items: stretch;
    }
    
    .chart-title {
        order: 1;
    }
    
    .chart-title h3 {
        font-size: 1rem;
    }
    
    .chart-title h3 .chart-icon {
        font-size: 1.2rem;
    }
    
    .chart-subtitle {
        font-size: 0.75rem;
    }
    
    .coin-info-badge {
        margin-top: 6px;
    }
    
    .coin-info-badge .badge {
        padding: 3px 8px;
        font-size: 0.7rem;
    }
    
    .chart-header-controls {
        order: 2;
        width: 100%;
        justify-content: space-between;
        margin-top: 10px;
    }
    
    .interval-selector {
        flex: 1;
    }
    
    .interval-label {
        display: none;
    }
    
    .interval-select {
        width: 100%;
        padding: 6px 10px;
        font-size: 0.85rem;
    }
    
    .chart-action-buttons {
        flex-wrap: nowrap;
        gap: 6px;
    }
    
    .btn-chart-action,
    .btn-chart-primary,
    .btn-chart-close {
        padding: 6px 10px;
        font-size: 0.9rem;
    }
    
    /* Hide certain buttons on mobile */
    .mobile-hide {
        display: none !important;
    }
    
    /* Compact buttons */
    .mobile-compact .desktop-text {
        display: none;
    }
    
    .mobile-compact .mobile-text {
        display: inline;
    }
    
    /* Show mobile menu toggle */
    .chart-mobile-menu-toggle {
        display: flex;
        order: 3;
        width: 100%;
        margin-top: 10px;
        justify-content: center;
    }
    
    .chart-mobile-menu-toggle.active {
        background: #ef5350;
    }
    
    /* Mobile Body */
    .chart-modal-body {
        flex-direction: column;
        height: calc(100vh - 180px); /* Header + collapsed footer */
    }
    
    .chart-widget-container {
        flex: 1;
        min-height: 300px;
        max-height: none;
        height: auto;
    }
    
    /* Sidebar as overlay on mobile */
    .chart-sidebar {
        position: fixed;
        top: 0;
        right: -100%;
        width: 85%;
        max-width: 320px;
        height: 100vh;
        z-index: 10001;
        transition: right 0.3s ease-out;
        box-shadow: -5px 0 15px rgba(0, 0, 0, 0.3);
    }
    
    .chart-sidebar.active {
        right: 0;
    }
    
    .sidebar-close-btn.mobile-only {
        display: block;
        position: absolute;
        top: 10px;
        right: 10px;
        background: #ef5350;
        color: #fff;
        border: none;
        width: 32px;
        height: 32px;
        border-radius: 50%;
        font-size: 1.2rem;
        cursor: pointer;
        z-index: 10;
    }
    
    /* Indicator tabs in single column on very small screens */
    .indicator-tabs {
        grid-template-columns: 1fr;
    }
    
    /* Footer adjustments - collapsed by default on mobile */
    .chart-modal-footer {
        max-height: 50px;
        padding: 0;
        overflow: hidden;
        transition: max-height 0.3s ease, padding 0.3s ease;
    }
    
    .chart-modal-footer.expanded {
        max-height: 300px;
        padding: 12px 15px;
        overflow-y: auto;
    }
    
    .footer-toggle-btn {
        display: block !important;
        padding: 12px;
        background: #252525;
        border-bottom: 1px solid #333;
        font-weight: 500;
    }
    
    .footer-toggle-btn:active {
        background: #2a2a2a;
    }
    
    .chart-modal-footer:not(.expanded) .indicator-info,
    .chart-modal-footer:not(.expanded) .market-info {
        display: none;
    }
    
    .indicator-stats-grid,
    .market-info-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }
    
    .stat-card,
    .market-card {
        padding: 10px;
    }
    
    .stat-label,
    .market-label {
        font-size: 0.7rem;
    }
    
    .stat-value,
    .market-value {
        font-size: 0.95rem;
    }
    
    .stat-desc,
    .market-change,
    .market-range,
    .market-rank,
    .market-trend {
        font-size: 0.7rem;
    }
    
    /* Toast adjustments */
    .chart-toast {
        bottom: 15px;
        right: 15px;
        left: 15px;
        width: auto;
    }
    
    .toast-content {
        font-size: 0.9rem;
    }
}

@media (max-width: 480px) {
    /* Even smaller screens */
    .chart-title h3 {
        font-size: 0.9rem;
    }
    
    .chart-modal-body {
        height: calc(100vh - 160px);
    }
    
    .chart-widget-container {
        min-height: 250px;
    }
    
    .indicator-stats-grid,
    .market-info-grid {
        grid-template-columns: 1fr;
    }
    
    .chart-sidebar {
        width: 90%;
    }
}

/* Landscape mobile orientation */
@media (max-height: 600px) and (orientation: landscape) {
    .tradingview-modal-content {
        height: 100vh;
    }
    
    .chart-modal-header {
        padding: 8px 15px;
    }
    
    .chart-widget-container {
        height: calc(100vh - 120px);
    }
    
    .chart-modal-footer {
        display: none;
    }
}

/* Desktop enhancements */
@media (min-width: 769px) {
    .mobile-only {
        display: none !important;
    }
    
    .mobile-text {
        display: none;
    }
    
    .desktop-text {
        display: inline;
    }
    
    .footer-toggle-btn {
        display: none !important;
    }
    
    .chart-modal-footer {
        max-height: 200px !important;
    }
}

/* Loading spinner for buttons */
.spinner-small {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* Error message styling */
.error-message {
    text-align: center;
    color: #ef5350;
}

.error-message p {
    margin: 10px 0;
}

.error-detail {
    font-size: 0.85rem;
    color: #888;
}

.btn-retry {
    margin-top: 15px;
    padding: 10px 20px;
    background: #26a69a;
    color: #fff;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
}

.btn-retry:hover {
    background: #2bbbad;
}
/* ============================================
   COLLAPSIBLE SIDEBAR & FOOTER STYLES
   ============================================ */

/* Hidden class for toggle arrows (shown only in fullscreen) */
.hidden {
    display: none !important;
}

/* Sidebar collapsed state */
.chart-sidebar.collapsed {
    width: 40px !important;
    min-width: 40px !important;
    overflow: hidden;
    transition: width 0.3s ease, min-width 0.3s ease;
}

.chart-sidebar.collapsed > *:not(.sidebar-toggle-arrow) {
    display: none;
}

/* Sidebar toggle arrow */
.sidebar-toggle-arrow {
    position: absolute;
    top: 50%;
    right: 8px;
    transform: translateY(-50%);
    background: rgba(38, 166, 154, 0.2);
    border: 1px solid rgba(38, 166, 154, 0.5);
    color: #26a69a;
    width: 28px;
    height: 28px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    transition: all 0.3s ease;
}

.sidebar-toggle-arrow:hover {
    background: rgba(38, 166, 154, 0.4);
    border-color: #26a69a;
    transform: translateY(-50%) scale(1.1);
}

/* When sidebar is not collapsed, arrow should rotate */
.chart-sidebar:not(.collapsed) .sidebar-toggle-arrow {
    transform: translateY(-50%) rotate(180deg);
}

/* Footer collapsed state */
.chart-modal-footer.collapsed {
    height: 40px;
    overflow: hidden;
    transition: height 0.3s ease;
}

.chart-modal-footer.collapsed .indicator-info,
.chart-modal-footer.collapsed .market-info {
    max-height: 0;
    overflow: hidden;
    padding: 0;
    margin: 0;
    opacity: 0;
    transition: max-height 0.3s ease, opacity 0.3s ease, padding 0.3s ease;
}

.chart-modal-footer:not(.collapsed) {
    height: auto;
    min-height: 200px;
}

.chart-modal-footer .indicator-info,
.chart-modal-footer .market-info {
    max-height: 500px;
    overflow-y: auto;
    opacity: 1;
    transition: max-height 0.3s ease, opacity 0.3s ease, padding 0.3s ease;
    padding: 15px;
}

/* Footer toggle button */
.footer-toggle-btn {
    width: 100%;
    padding: 10px;
    background: rgba(38, 166, 154, 0.1);
    border: none;
    color: #26a69a;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
}

.footer-toggle-btn:hover {
    background: rgba(38, 166, 154, 0.2);
}

/* Interval badge styling */
.interval-badge {
    background: rgba(38, 166, 154, 0.1);
    border: 1px solid rgba(38, 166, 154, 0.3);
    color: #26a69a;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 15px;
    text-align: center;
}

/* Fullscreen mode adjustments */
.tradingview-modal-content:fullscreen .sidebar-toggle-arrow,
.tradingview-modal-content:fullscreen .footer-toggle-btn {
    display: flex !important;
}

/* Smooth transitions for all collapsible elements */
.chart-sidebar,
.chart-modal-footer,
.sidebar-toggle-arrow,
.footer-toggle-btn {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Mobile responsiveness */
@media (max-width: 768px) {
    .sidebar-toggle-arrow {
        display: none !important;
    }
    
    .chart-sidebar.collapsed {
        width: 0 !important;
        min-width: 0 !important;
    }
}

/* Ensure smooth animations on fullscreen toggle */
.tradingview-modal-content {
    transition: all 0.3s ease;
}

/* Loading and error states */
.info-loading,
.info-error {
    padding: 20px;
    text-align: center;
    color: #888;
    font-size: 14px;
}

.info-error {
    color: #ef5350;
}

/* Stats grid and cards */
.indicator-stats-grid,
.market-info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    padding: 15px;
}

.stat-card,
.market-card {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 15px;
    transition: all 0.2s;
}

.stat-card:hover,
.market-card:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(38, 166, 154, 0.3);
}

.stat-label,
.market-label {
    font-size: 11px;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.stat-value,
.market-value {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 5px;
}

.stat-desc,
.market-change,
.market-trend {
    font-size: 12px;
    color: #aaa;
}

/* Color classes */
.overbought { color: #ef5350; }
.oversold { color: #26a69a; }
.bullish { color: #26a69a; }
.bearish { color: #ef5350; }
.neutral { color: #888; }
.positive { color: #26a69a; }
.negative { color: #ef5350; }
.high { color: #ff9800; }
.medium { color: #fdd835; }
.low { color: #888; }
.normal { color: #aaa; }

/* Scrollbar styling */
.indicator-info::-webkit-scrollbar,
.market-info::-webkit-scrollbar {
    width: 6px;
}

.indicator-info::-webkit-scrollbar-track,
.market-info::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 3px;
}

.indicator-info::-webkit-scrollbar-thumb,
.market-info::-webkit-scrollbar-thumb {
    background: rgba(38, 166, 154, 0.3);
    border-radius: 3px;
}

.indicator-info::-webkit-scrollbar-thumb:hover,
.market-info::-webkit-scrollbar-thumb:hover {
    background: rgba(38, 166, 154, 0.5);
}