/* Responsive Design */

/* Large Desktop (1920px+) */
@media (min-width: 1920px) {
    .trading-panel {
        max-width: 1400px;
    }
    
    .chart-container {
        min-height: 600px;
    }
    
    .sidebar {
        width: 320px;
    }
}

/* Desktop (1200px - 1919px) */
@media (min-width: 1200px) and (max-width: 1919px) {
    .trading-panel {
        max-width: 100%;
    }
    
    .sidebar {
        width: 280px;
    }
}

/* Laptop (992px - 1199px) */
@media (min-width: 992px) and (max-width: 1199px) {
    .header {
        padding: var(--spacing-sm) var(--spacing-md);
    }
    
    .header-center {
        display: none;
    }
    
    .sidebar {
        width: 240px;
    }
    
    .sidebar.collapsed {
        width: 50px;
    }
    
    .tool-buttons {
        grid-template-columns: 1fr;
    }
    
    .trade-form {
        gap: var(--spacing-md);
    }
    
    .form-group input {
        width: 100px;
    }
    
    .trade-btn {
        min-width: 100px;
        padding: var(--spacing-sm) var(--spacing-md);
    }
}

/* Tablet (768px - 991px) */
@media (min-width: 768px) and (max-width: 991px) {
    .app {
        flex-direction: column;
    }
    
    .main-content {
        flex-direction: column;
        height: calc(100vh - 120px);
    }
    
    .sidebar {
        width: 100%;
        height: auto;
        max-height: 200px;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }
    
    .sidebar-left {
        order: 1;
    }
    
    .sidebar-right {
        order: 3;
        border-left: none;
        border-top: 1px solid var(--border-color);
    }
    
    .chart-container {
        order: 2;
        height: calc(100% - 400px);
        min-height: 300px;
    }
    
    .header {
        flex-wrap: wrap;
        gap: var(--spacing-sm);
    }
    
    .header-center {
        order: 3;
        width: 100%;
        margin-top: var(--spacing-sm);
    }
    
    .price-display {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: var(--spacing-lg);
    }
    
    .current-price {
        font-size: 1.5rem;
    }
    
    .trading-controls {
        padding: var(--spacing-sm) var(--spacing-md);
    }
    
    .trade-form {
        flex-wrap: wrap;
        gap: var(--spacing-sm);
    }
    
    .form-group input {
        width: 80px;
    }
    
    .trade-btn {
        min-width: 80px;
        padding: var(--spacing-sm);
        font-size: 0.9rem;
    }
    
    .quick-trade {
        display: none;
    }
    
    .timeframe-selector {
        flex-wrap: wrap;
        gap: var(--spacing-xs);
    }
    
    .timeframe-btn {
        font-size: 0.7rem;
        padding: var(--spacing-xs);
    }
}

/* Mobile Large (576px - 767px) */
@media (min-width: 576px) and (max-width: 767px) {
    .app {
        flex-direction: column;
    }
    
    .main-content {
        flex-direction: column;
        height: calc(100vh - 140px);
    }
    
    .sidebar {
        width: 100%;
        height: auto;
        max-height: 150px;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }
    
    .sidebar-left {
        order: 1;
    }
    
    .sidebar-right {
        order: 3;
        border-left: none;
        border-top: 1px solid var(--border-color);
        max-height: 120px;
    }
    
    .chart-container {
        order: 2;
        height: calc(100% - 270px);
        min-height: 250px;
    }
    
    .header {
        flex-direction: column;
        gap: var(--spacing-sm);
        padding: var(--spacing-sm);
        min-height: auto;
    }
    
    .header-left {
        width: 100%;
        justify-content: space-between;
    }
    
    .header-center {
        width: 100%;
        order: 2;
    }
    
    .header-right {
        width: 100%;
        justify-content: space-between;
        order: 3;
    }
    
    .price-display {
        display: flex;
        align-items: center;
        justify-content: space-between;
        width: 100%;
    }
    
    .current-price {
        font-size: 1.3rem;
    }
    
    .price-change {
        flex-direction: column;
        align-items: flex-end;
        gap: var(--spacing-xs);
    }
    
    .trading-controls {
        padding: var(--spacing-sm);
    }
    
    .trading-panel {
        flex-direction: column;
        gap: var(--spacing-md);
    }
    
    .trade-form {
        width: 100%;
        justify-content: space-between;
        flex-wrap: wrap;
    }
    
    .form-group {
        flex: 1;
        min-width: 80px;
    }
    
    .form-group input {
        width: 100%;
    }
    
    .trade-buttons {
        width: 100%;
        justify-content: space-between;
    }
    
    .trade-btn {
        flex: 1;
        min-width: 0;
    }
    
    .chart-header {
        padding: var(--spacing-sm);
        flex-direction: column;
        gap: var(--spacing-sm);
    }
    
    .timeframe-selector {
        width: 100%;
        justify-content: center;
        flex-wrap: wrap;
    }
    
    .chart-controls {
        width: 100%;
        justify-content: center;
    }
    
    .status-bar {
        flex-direction: column;
        gap: var(--spacing-xs);
        padding: var(--spacing-xs) var(--spacing-sm);
    }
    
    .status-left,
    .status-center,
    .status-right {
        width: 100%;
        text-align: center;
    }
}

/* Mobile Small (320px - 575px) */
@media (max-width: 575px) {
    .app {
        flex-direction: column;
    }
    
    .main-content {
        flex-direction: column;
        height: calc(100vh - 160px);
    }
    
    .sidebar {
        width: 100%;
        height: auto;
        max-height: 120px;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }
    
    .sidebar-left {
        order: 1;
    }
    
    .sidebar-right {
        order: 3;
        border-left: none;
        border-top: 1px solid var(--border-color);
        max-height: 100px;
    }
    
    .chart-container {
        order: 2;
        height: calc(100% - 220px);
        min-height: 200px;
    }
    
    .header {
        flex-direction: column;
        gap: var(--spacing-xs);
        padding: var(--spacing-xs);
        min-height: auto;
    }
    
    .header-left {
        width: 100%;
        justify-content: space-between;
    }
    
    .logo {
        font-size: 1.2rem;
    }
    
    .logo i {
        font-size: 1.4rem;
    }
    
    .pair-selector select {
        font-size: 0.9rem;
        padding: var(--spacing-xs) var(--spacing-sm);
    }
    
    .header-center {
        width: 100%;
        order: 2;
    }
    
    .header-right {
        width: 100%;
        justify-content: space-between;
        order: 3;
    }
    
    .price-display {
        display: flex;
        align-items: center;
        justify-content: space-between;
        width: 100%;
    }
    
    .current-price {
        font-size: 1.1rem;
    }
    
    .price-change {
        flex-direction: column;
        align-items: flex-end;
        gap: var(--spacing-xs);
        font-size: 0.8rem;
    }
    
    .user-info {
        gap: var(--spacing-sm);
    }
    
    .balance {
        align-items: flex-end;
    }
    
    .balance-label {
        font-size: 0.7rem;
    }
    
    .balance-value {
        font-size: 0.9rem;
    }
    
    .trading-controls {
        padding: var(--spacing-xs);
    }
    
    .trading-panel {
        flex-direction: column;
        gap: var(--spacing-sm);
    }
    
    .trade-form {
        width: 100%;
        flex-direction: column;
        gap: var(--spacing-sm);
    }
    
    .form-group {
        width: 100%;
    }
    
    .form-group input {
        width: 100%;
    }
    
    .trade-buttons {
        width: 100%;
        gap: var(--spacing-sm);
    }
    
    .trade-btn {
        flex: 1;
        min-width: 0;
        padding: var(--spacing-sm);
        font-size: 0.8rem;
    }
    
    .chart-header {
        padding: var(--spacing-xs);
        flex-direction: column;
        gap: var(--spacing-xs);
    }
    
    .timeframe-selector {
        width: 100%;
        justify-content: center;
        flex-wrap: wrap;
        gap: var(--spacing-xs);
    }
    
    .timeframe-btn {
        font-size: 0.7rem;
        padding: var(--spacing-xs);
        min-width: 35px;
    }
    
    .chart-controls {
        width: 100%;
        justify-content: center;
        gap: var(--spacing-xs);
    }
    
    .control-btn {
        width: 32px;
        height: 32px;
        padding: var(--spacing-xs);
    }
    
    .status-bar {
        flex-direction: column;
        gap: var(--spacing-xs);
        padding: var(--spacing-xs);
        font-size: 0.7rem;
    }
    
    .status-left,
    .status-center,
    .status-right {
        width: 100%;
        text-align: center;
    }
    
    .modal-content {
        width: 95%;
        margin: var(--spacing-sm);
    }
    
    .modal-header {
        padding: var(--spacing-md);
    }
    
    .modal-body {
        padding: var(--spacing-md);
    }
    
    .user-settings {
        gap: var(--spacing-md);
    }
}

/* Landscape Mobile */
@media (max-height: 500px) and (orientation: landscape) {
    .app {
        flex-direction: row;
    }
    
    .main-content {
        flex-direction: row;
        height: calc(100vh - 60px);
    }
    
    .sidebar {
        width: 200px;
        height: 100%;
        max-height: none;
        border-right: 1px solid var(--border-color);
        border-bottom: none;
    }
    
    .sidebar-right {
        border-left: 1px solid var(--border-color);
        border-top: none;
        max-height: none;
    }
    
    .chart-container {
        height: 100%;
        min-height: 200px;
    }
    
    .header {
        flex-direction: row;
        padding: var(--spacing-sm) var(--spacing-md);
    }
    
    .header-center {
        order: 0;
        width: auto;
    }
    
    .header-right {
        order: 0;
        width: auto;
    }
    
    .trading-controls {
        padding: var(--spacing-sm) var(--spacing-md);
    }
    
    .trading-panel {
        flex-direction: row;
        gap: var(--spacing-md);
    }
    
    .trade-form {
        flex-direction: row;
        gap: var(--spacing-sm);
    }
    
    .form-group input {
        width: 80px;
    }
    
    .trade-btn {
        min-width: 80px;
        padding: var(--spacing-sm);
    }
}

/* High DPI Displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .logo i,
    .tool-btn i,
    .control-btn i {
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
    }
}

/* Print Styles */
@media print {
    .app {
        display: none;
    }
    
    body::before {
        content: "Trading Platform - Não disponível para impressão";
        display: block;
        text-align: center;
        padding: 2rem;
        font-size: 1.5rem;
        color: #333;
    }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

@media (prefers-color-scheme: light) {
    :root {
        --bg-primary: #ffffff;
        --bg-secondary: #f8f9fa;
        --bg-tertiary: #e9ecef;
        --bg-card: #ffffff;
        
        --text-primary: #212529;
        --text-secondary: #6c757d;
        --text-muted: #adb5bd;
        
        --border-color: #dee2e6;
        --border-light: #e9ecef;
        
        --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.1);
        --shadow-md: 0 4px 8px rgba(0, 0, 0, 0.15);
        --shadow-lg: 0 8px 16px rgba(0, 0, 0, 0.2);
    }
}

/* Focus Styles for Keyboard Navigation */
@media (any-hover: none) {
    .tool-btn:focus,
    .timeframe-btn:focus,
    .control-btn:focus,
    .trade-btn:focus,
    .quick-btn:focus {
        outline: 2px solid var(--accent-primary);
        outline-offset: 2px;
    }
}

/* Touch Device Optimizations */
@media (hover: none) and (pointer: coarse) {
    .tool-btn,
    .timeframe-btn,
    .control-btn,
    .trade-btn,
    .quick-btn {
        min-height: 44px;
        min-width: 44px;
    }
    
    .form-group input {
        min-height: 44px;
    }
    
    .sidebar-toggle {
        min-height: 44px;
        min-width: 44px;
    }
}

