/* Spin animation for refresh button */
@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

body {
  font-family: Arial, sans-serif;
  margin: 20px;
  color: #333;
}

table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 20px;
  box-shadow: 0 2px 3px rgba(0, 0, 0, 0.1);
}

th,
td {
  padding: 12px 15px;
  text-align: left;
  border-bottom: 1px solid #ddd;
}

th {
  background-color: #4CAF50;
  color: white;
  cursor: pointer;
  position: sticky;
  top: 0;
}

th:hover {
  background-color: #45a049;
}

/* Active market styles take precedence */
tr[data-active="true"] {
  background-color: #99ccff !important;
  cursor: pointer;
}

tr[data-active="true"]:hover {
  background-color: #66b3ff !important;
}

/* Regular row styles */
tr:not([data-active="true"]):nth-child(even) {
  background-color: #f2f2f2;
}

tr:not([data-active="true"]):hover {
  background-color: #d9d9d9 !important;
}

.reward-cell {
  font-weight: bold;
  color: #2a6496;
}

.search-container {
  position: relative;
  display: inline-block;
}

#search-box {
  padding: 8px 70px 8px 12px;  /* Increased right padding for wider button */
  margin-bottom: 15px;
  width: 300px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 14px;
  height: 36px;  /* Explicitly set height */
  box-sizing: border-box;  /* Include padding in height calculation */
}

.clear-search {
  position: absolute;
  right: 4px;
  top: 6px;  /* Fixed position from top instead of using transform */
  cursor: pointer;
  color: #666;
  font-size: 13px;
  padding: 4px 10px;
  border: 1px solid #ddd;
  border-radius: 3px;
  background-color: #f8f8f8;
  display: none;  /* Hidden by default */
  height: 24px;  /* Fixed height */
  line-height: 14px;  /* Center text vertically */
}

.clear-search:hover {
  background-color: #f0f0f0;
  border-color: #ccc;
}

/* Show clear button when search has content */
#search-box:not(:placeholder-shown) + .clear-search {
  display: block;
}
/* Modal styles */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1000;
}

.modal-content {
    position: relative;
    background-color: #fff;
    margin: 15% auto;
    padding: 20px;
    border-radius: 5px;
    width: 400px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.modal-header {
    margin-bottom: 20px;
}

.modal-header h2 {
    margin: 0;
    font-size: 18px;
    color: #333;
}

.modal-body {
    margin-bottom: 20px;
}

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
    color: #666;
}

.form-group input {
    width: 100%;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    box-sizing: border-box;
}

.modal-footer {
    text-align: right;
}

.modal-footer button {
    padding: 8px 15px;
    margin-left: 10px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
}

.btn-cancel {
    background-color: #f0f0f0;
    color: #666;
}

.btn-save {
    background-color: #4CAF50;
    color: white;
}

.btn-save:hover {
    background-color: #45a049;
}

.btn-cancel:hover {
    background-color: #e4e4e4;
}

/* ============================================
   MOBILE RESPONSIVE STYLES
   ============================================ */

/* Dashboard Main Grid - 2 column layout */
.dashboard-grid {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(0, 3fr);
    gap: 20px;
    margin-bottom: 20px;
    align-items: start;
    width: 100%;
    box-sizing: border-box;
    contain: layout;
}

/* Dashboard Columns */
.dashboard-column {
    display: flex;
    flex-direction: column;
    gap: 20px;
    min-width: 0; /* Prevent grid blowout */
    max-width: 100%;
    box-sizing: border-box;
    position: relative;
}

.column-left {
    /* Left column: Setup + Order Entry */
    grid-column: 1;
}

.column-right {
    /* Right column: Chart + Volatility Cards */
    grid-column: 2;
    overflow: hidden;
}

/* Dashboard Sections */
.dashboard-section {
    width: 100%;
    max-width: 100%;
    position: relative;
    box-sizing: border-box;
}

.section-setup,
.section-order-entry {
    overflow: hidden;
}

/* Ensure all child elements don't overflow */
.dashboard-grid *,
.dashboard-column * {
    box-sizing: border-box;
}

/* Chart Section */
.section-chart {
    height: 450px;
}

/* Chart Container */
.chart-container {
    background: white;
    border-radius: 12px;
    padding: 0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    height: 100%;
    overflow: hidden;
}

/* TradingView Widget fills container */
.chart-container .tradingview-widget-container {
    height: 100% !important;
    width: 100% !important;
}

.chart-container .tradingview-widget-container__widget {
    height: calc(100% - 24px) !important;
    width: 100% !important;
}

.chart-container .tradingview-widget-container iframe {
    height: 100% !important;
    width: 100% !important;
}

/* Volatility Cards Grid */
.volatility-cards-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    width: 100%;
}

/* Info Cards Grid */
.info-cards-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
    margin-bottom: 0;
    width: 100%;
}

/* Trading Buttons Grid */
.trading-buttons-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    width: 100%;
}

/* Setup Header */
.setup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    border-bottom: 1px solid #eee;
    padding-bottom: 16px;
}

.market-type-selector {
    display: flex;
    gap: 20px;
    align-items: center;
}

/* Mobile Menu Button */
.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #fff;
    padding: 8px;
}

/* ============================================
   MOBILE BREAKPOINT (max-width: 768px)
   ============================================ */
@media (max-width: 768px) {
    body {
        margin: 10px;
    }
    
    /* Single column layout on mobile - flatten the nested structure */
    .dashboard-grid {
        display: flex;
        flex-direction: column;
        gap: 12px;
    }
    
    /* Flatten columns on mobile */
    .dashboard-column {
        display: contents;
    }
    
    /* Reorder sections for mobile using order */
    .section-setup {
        order: 1;
    }
    
    .section-chart {
        order: 2;
    }
    
    .section-volatility {
        order: 3;
        margin-top: 0 !important;
    }
    
    .section-order-entry {
        order: 4;
        margin-top: 0 !important;
    }
    
    /* Full width sections */
    .dashboard-section {
        width: 100%;
    }
    
    /* Setup header stays horizontal on mobile */
    .setup-header {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 10px;
        align-items: center;
        justify-content: space-between;
    }
    
    .market-type-selector {
        gap: 12px;
    }
    
    .market-type-selector label {
        font-size: 13px !important;
    }
    
    /* Info cards - keep 4 across but compact */
    .info-cards-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 6px;
    }
    
    /* Compact info cards */
    .info-cards-grid > div {
        padding: 8px 4px !important;
    }
    
    .info-cards-grid .card-label {
        font-size: 8px !important;
        letter-spacing: 0 !important;
    }
    
    .info-cards-grid .card-value {
        font-size: 13px !important;
    }
    
    /* Volatility cards stay side by side but compact */
    .volatility-cards-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 6px;
    }
    
    /* Compact volatility cards */
    .volatility-card {
        padding: 10px !important;
    }
    
    .volatility-card h3 {
        font-size: 12px !important;
    }
    
    /* Chart section for mobile - slightly smaller but chart fills it */
    .section-chart {
        height: 380px;
    }
    
    .chart-container {
        height: 100%;
        padding: 0;
    }
    
    /* Hide drawing tools on mobile */
    .tradingview-widget-container iframe {
        /* TradingView will need hide_side_toolbar set via JS for mobile */
    }
    
    /* Trading buttons */
    .trading-buttons-grid button {
        padding: 12px !important;
        font-size: 15px !important;
    }
    
    /* Order entry section */
    .section-order-entry {
        padding: 16px !important;
    }
    
    /* Setup form padding */
    #crypto-setup-form {
        padding: 16px !important;
    }
    
    /* Show mobile menu button */
    .mobile-menu-btn {
        display: block;
    }
    
    /* Header adjustments */
    .header {
        flex-wrap: wrap;
        padding: 12px;
    }
    
    .header .logo {
        font-size: 18px;
    }
    
    .user-info {
        font-size: 12px;
    }
    
    /* Navigation dropdown adjustments */
    .nav-menu {
        position: fixed;
        top: 60px;
        left: 0;
        right: 0;
        background: #1a1a2e;
        flex-direction: column;
        padding: 16px;
        display: none;
        z-index: 1000;
    }
    
    .nav-menu.active {
        display: flex;
    }
    
    .nav-item {
        width: 100%;
    }
    
    .dropdown-content {
        position: static;
        box-shadow: none;
        background: rgba(255,255,255,0.05);
        margin-top: 8px;
    }
}

/* ============================================
   SMALL MOBILE BREAKPOINT (max-width: 480px)
   ============================================ */
@media (max-width: 480px) {
    body {
        margin: 6px;
    }
    
    /* Even more compact info cards */
    .info-cards-grid {
        gap: 4px;
    }
    
    .info-cards-grid > div {
        padding: 6px 2px !important;
    }
    
    .info-cards-grid .card-label {
        font-size: 7px !important;
    }
    
    .info-cards-grid .card-value {
        font-size: 11px !important;
    }
    
    /* Bid/Ask card special handling */
    .info-cards-grid > div:last-child {
        font-size: 10px !important;
    }
    
    /* Smaller buttons */
    .trading-buttons-grid button {
        padding: 10px !important;
        font-size: 14px !important;
    }
    
    /* Chart section for small mobile */
    .section-chart {
        height: 350px;
    }
    
    .chart-container {
        height: 100%;
        padding: 0;
    }
    
    /* More compact volatility cards */
    .volatility-card {
        padding: 8px !important;
    }
    
    .volatility-card h3 {
        font-size: 11px !important;
    }
    
    /* Setup form padding */
    #crypto-setup-form {
        padding: 12px !important;
    }
    
    /* Compact setup header */
    .setup-header {
        gap: 8px;
    }
    
    .market-type-selector {
        gap: 8px;
    }
    
    .market-type-selector label {
        font-size: 12px !important;
    }
    
    /* Start button smaller */
    #crypto-start-btn, #crypto-stop-btn {
        padding: 10px 16px !important;
        font-size: 12px !important;
    }
}
