/**
 * Responsive Design - Mobile, Tablet, and Desktop
 */

/* ========== TABLET (768px and up) ========== */
@media (max-width: 1024px) {
    .page-layout {
        grid-template-columns: 1fr;
        gap: var(--spacing-lg);
    }

    .sidebar-area {
        grid-column: 1;
    }

    .top-panel-container {
        flex-direction: column;
        gap: var(--spacing-lg);
    }

    .rates-section {
        width: 100%;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .admin-table-container {
        overflow-x: auto;
    }
}

/* ========== MOBILE (768px and below) ========== */
@media (max-width: 768px) {
    :root {
        --sidebar-width: 100%;
        font-size: 14px;
    }

    #app {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        position: fixed;
        height: 100vh;
        left: -100%;
        top: 0;
        transition: left 0.3s ease;
        z-index: 1000;
    }

    .sidebar.open {
        left: 0;
    }

    .sidebar-close {
        display: block;
    }

    .main-container {
        width: 100%;
    }

    .top-panel {
        padding: var(--spacing-lg) var(--spacing-md);
    }

    .main-content {
        padding: var(--spacing-lg) var(--spacing-md);
    }

    .page-header {
        margin-bottom: var(--spacing-lg);
    }

    h1 {
        font-size: 1.5rem;
    }

    h2 {
        font-size: 1.25rem;
    }

    h3 {
        font-size: 1rem;
    }

    /* Navigation */
    .nav-label {
        display: none;
    }

    .nav-item {
        justify-content: center;
        padding: var(--spacing-md);
    }

    /* Forms */
    .form-row {
        grid-template-columns: 1fr;
    }

    /* Buttons */
    .btn {
        width: 100%;
    }

    .btn-small {
        width: auto;
    }

    /* Tables */
    .admin-table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    table {
        min-width: 600px;
    }

    .transactions-table {
        overflow-x: auto;
    }

    /* Cards */
    .balance-card {
        padding: var(--spacing-lg);
    }

    .balance-amount {
        font-size: 1.75rem;
    }

    /* Grid Layouts */
    .accounts-grid {
        grid-template-columns: 1fr;
    }

    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }

    /* Sidebar area */
    .page-layout {
        grid-template-columns: 1fr;
    }

    .sidebar-area {
        grid-column: 1;
    }

    /* Top Panel */
    .top-panel-container {
        flex-direction: column;
    }

    .rates-section {
        flex-direction: column;
        width: 100%;
    }

    .rate-item {
        min-width: auto;
    }

    .user-wallet-section {
        width: 100%;
    }

    /* Quick Actions */
    .quick-actions {
        grid-template-columns: 1fr 1fr;
    }
}

/* ========== SMALL MOBILE (480px and below) ========== */
@media (max-width: 480px) {
    :root {
        font-size: 13px;
    }

    .main-content {
        padding: var(--spacing-md);
    }

    .top-panel {
        padding: var(--spacing-md);
    }

    .page-header {
        margin-bottom: var(--spacing-md);
    }

    h1 {
        font-size: 1.25rem;
    }

    h2 {
        font-size: 1rem;
    }

    h3 {
        font-size: 0.95rem;
    }

    .section {
        padding: var(--spacing-lg) var(--spacing-md);
        border-radius: 6px;
    }

    .balance-card {
        padding: var(--spacing-lg) var(--spacing-md);
    }

    .balance-amount {
        font-size: 1.5rem;
    }

    .balance-header {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--spacing-sm);
    }

    /* Forms */
    .form-control {
        padding: var(--spacing-md);
        font-size: 16px;
    }

    /* Buttons */
    .btn {
        padding: var(--spacing-md);
        font-size: 0.9rem;
    }

    /* Account Cards Grid */
    .accounts-grid {
        grid-template-columns: 1fr;
        gap: var(--spacing-md);
    }

    .account-card {
        padding: var(--spacing-md);
    }

    /* Tables */
    table {
        font-size: 0.85rem;
    }

    th, td {
        padding: var(--spacing-sm);
    }

    /* Grid columns */
    .stats-grid {
        grid-template-columns: 1fr;
        gap: var(--spacing-md);
    }

    .info-grid {
        grid-template-columns: 1fr;
        gap: var(--spacing-md);
    }

    .balance-grid {
        grid-template-columns: 1fr;
        gap: var(--spacing-md);
    }

    /* Quick Actions */
    .quick-actions {
        grid-template-columns: 1fr;
        gap: var(--spacing-md);
    }

    .action-btn {
        padding: var(--spacing-md);
    }

    /* Top Panel */
    .rate-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .rate-value {
        font-size: 1.25rem;
    }

    /* Crypto Selector */
    .crypto-selector {
        grid-template-columns: 1fr;
    }

    .crypto-btn {
        padding: var(--spacing-md);
    }

    /* Transaction Type Selector */
    .transaction-type-selector {
        grid-template-columns: 1fr;
    }

    .type-btn {
        padding: var(--spacing-md);
    }

    /* Client Details */
    .client-details-header {
        flex-direction: column;
        text-align: center;
    }

    .client-avatar {
        width: 60px;
        height: 60px;
        margin: 0 auto var(--spacing-md);
    }

    /* Admin Actions */
    .admin-actions {
        flex-direction: column;
    }

    .admin-actions .btn {
        width: 100%;
    }
}

/* ========== LANDSCAPE MODE (max-height) ========== */
@media (max-height: 600px) {
    .sidebar {
        height: auto;
        max-height: 100vh;
        overflow-y: auto;
    }

    .top-panel {
        padding: var(--spacing-md);
    }

    .main-content {
        padding: var(--spacing-md);
    }
}

/* ========== PRINT STYLES ========== */
@media print {
    .sidebar,
    .top-panel,
    .sidebar-area,
    .btn,
    .logout-btn {
        display: none;
    }

    body {
        background: white;
    }

    .main-container {
        background: white;
    }

    .section {
        page-break-inside: avoid;
        box-shadow: none;
        border: 1px solid #ccc;
    }

    a {
        color: #0066cc;
    }
}

/* ========== DARK MODE (Optional) ========== */
@media (prefers-color-scheme: dark) {
    :root {
        --bg-primary: #1f2937;
        --bg-secondary: #111827;
        --bg-tertiary: #374151;
        --text-primary: #f3f4f6;
        --text-secondary: #d1d5db;
        --text-tertiary: #9ca3af;
        --border-color: #374151;
        --border-color-dark: #4b5563;
    }
}

/* ========== FOCUS VISIBLE (Accessibility) ========== */
*:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

button:focus-visible,
a:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* ========== HIGH CONTRAST MODE ========== */
@media (prefers-contrast: more) {
    .btn-primary {
        border: 2px solid var(--primary-dark);
    }

    .btn-secondary {
        border: 2px solid var(--text-primary);
    }

    .nav-item {
        border-left-width: 4px;
    }
}

/* ========== REDUCED MOTION ========== */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
