/* assets/css/style.css */

:root {
    --bg-primary: #0d1117;
    --bg-secondary: #161b22;
    --bg-tertiary: #1c2333;
    --bg-card: #1a1f2e;
    --bg-input: #0d1117;
    --border-color: #30363d;
    --text-primary: #e6edf3;
    --text-secondary: #8b949e;
    --text-muted: #484f58;
    --accent-primary: #58a6ff;
    --accent-green: #3fb950;
    --accent-red: #f85149;
    --accent-yellow: #d29922;
    --accent-purple: #bc8cff;
    --gradient-primary: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --gradient-green: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
    --shadow-lg: 0 10px 40px rgba(0, 0, 0, 0.4);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-secondary); }
::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 3px; }

/* Navbar */
.navbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    height: 64px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 20px;
    font-weight: 700;
    color: var(--accent-primary);
}

.nav-brand i { font-size: 24px; }

.nav-tabs {
    display: flex;
    gap: 4px;
    background: var(--bg-tertiary);
    padding: 4px;
    border-radius: var(--radius-md);
}

.nav-tab {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
}

.nav-tab:hover { color: var(--text-primary); background: rgba(255,255,255,0.05); }
.nav-tab.active { color: var(--text-primary); background: var(--bg-card); }

.nav-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.network-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    font-size: 13px;
    color: var(--text-secondary);
}

.network-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent-green);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

.btn-primary {
    background: var(--gradient-primary);
    color: white;
}

.btn-primary:hover { opacity: 0.9; transform: translateY(-1px); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover { border-color: var(--accent-primary); }

.btn-danger {
    background: rgba(248, 81, 73, 0.15);
    color: var(--accent-red);
    border: 1px solid rgba(248, 81, 73, 0.3);
}

.btn-lg { padding: 14px 28px; font-size: 16px; }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-full { width: 100%; justify-content: center; }

.btn-icon {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 8px;
    border-radius: var(--radius-sm);
    transition: all 0.2s;
    font-size: 16px;
}

.btn-icon:hover { color: var(--text-primary); background: rgba(255,255,255,0.05); }

.btn-switch {
    background: var(--bg-card);
    border: 4px solid var(--bg-primary);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent-primary);
}

.btn-switch:hover { transform: rotate(180deg); }

/* Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px;
}

/* Cards */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-lg);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.card-header h2 {
    font-size: 18px;
    font-weight: 600;
}

/* Tabs */
.tab-content { display: none; }
.tab-content.active { display: block; animation: fadeIn 0.3s ease; }

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Swap Container */
.swap-container, .limit-container {
    max-width: 480px;
    margin: 0 auto;
}

/* Token Input */
.token-input-container {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px;
    margin-bottom: 4px;
    transition: border-color 0.2s;
}

.token-input-container:focus-within { border-color: var(--accent-primary); }

.token-input-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 13px;
    color: var(--text-secondary);
}

.token-input-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.token-input-row input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 28px;
    font-weight: 500;
    outline: none;
    min-width: 0;
}

.token-input-row input::placeholder { color: var(--text-muted); }

.token-input-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 8px;
    font-size: 13px;
    color: var(--text-secondary);
}

.quick-amounts {
    display: flex;
    gap: 4px;
}

.quick-amt {
    background: rgba(88, 166, 255, 0.1);
    border: none;
    color: var(--accent-primary);
    padding: 2px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
}

.quick-amt:hover { background: rgba(88, 166, 255, 0.2); }

.token-selector {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: 8px 12px;
    color: var(--text-primary);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.token-selector:hover { border-color: var(--accent-primary); background: var(--bg-secondary); }

.token-logo {
    width: 24px;
    height: 24px;
    border-radius: 50%;
}

.swap-direction {
    display: flex;
    justify-content: center;
    margin: -14px 0;
    position: relative;
    z-index: 2;
}

/* Settings Panel */
.settings-panel {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px;
    margin-bottom: 16px;
}

.setting-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.setting-row label { font-size: 14px; color: var(--text-secondary); }

.slippage-options {
    display: flex;
    gap: 8px;
    align-items: center;
}

.slippage-btn {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s;
}

.slippage-btn.active, .slippage-btn:hover {
    background: rgba(88, 166, 255, 0.15);
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

.slippage-options input {
    width: 70px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 6px 8px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    outline: none;
}

/* Swap Info */
.swap-info, .order-summary {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 12px 16px;
    margin: 12px 0;
}

.info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 0;
    font-size: 13px;
}

.info-row span:first-child { color: var(--text-secondary); }

/* Price Input */
.price-input-container {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px;
    margin: 12px 0;
}

.price-input-container label {
    font-size: 13px;
    color: var(--text-secondary);
    display: block;
    margin-bottom: 8px;
}

.price-input-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.price-input-row input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 24px;
    font-weight: 500;
    outline: none;
}

.price-helpers {
    display: flex;
    gap: 6px;
    margin-top: 10px;
}

.price-helper {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 4px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s;
}

.price-helper:hover {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

/* Expiry */
.expiry-container {
    padding: 12px 0;
    font-size: 14px;
    color: var(--text-secondary);
}

.expiry-container label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.expiry-container select {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    margin-top: 8px;
    outline: none;
}

/* Orderbook */
.orderbook-container .card { max-width: 800px; margin: 0 auto; }

.pair-selector {
    display: flex;
    align-items: center;
    gap: 8px;
}

.select-token {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    outline: none;
}

.orderbook-grid {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.orderbook-header {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    padding: 8px 12px;
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border-color);
}

.orderbook-rows {
    max-height: 250px;
    overflow-y: auto;
}

.orderbook-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    padding: 6px 12px;
    font-size: 13px;
    font-family: 'JetBrains Mono', monospace, 'Inter';
    cursor: pointer;
    transition: background 0.1s;
    position: relative;
}

.orderbook-row:hover { background: rgba(255,255,255,0.03); }

.orderbook-row .fill-bar {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    opacity: 0.1;
}

.asks .orderbook-row .price { color: var(--accent-red); }
.asks .fill-bar { background: var(--accent-red); }
.bids .orderbook-row .price { color: var(--accent-green); }
.bids .fill-bar { background: var(--accent-green); }

.orderbook-spread {
    padding: 8px 12px;
    text-align: center;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    background: var(--bg-input);
    border-top: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
}

/* Token Manager */
.tokens-container .card { max-width: 600px; margin: 0 auto; }

.add-token-form {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 20px;
    margin-bottom: 24px;
}

.add-token-form h3 {
    font-size: 16px;
    margin-bottom: 16px;
    color: var(--text-secondary);
}

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

.form-group label {
    display: block;
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.form-group input, .form-group select {
    width: 100%;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

.form-group input:focus { border-color: var(--accent-primary); }

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.input-with-btn {
    display: flex;
    gap: 8px;
}

.input-with-btn input { flex: 1; }

.search-bar {
    position: relative;
    margin-bottom: 16px;
}

.search-bar i {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.search-bar input {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 12px 14px 12px 40px;
    border-radius: var(--radius-md);
    font-size: 14px;
    outline: none;
}

.token-list {
    max-height: 400px;
    overflow-y: auto;
}

.token-list-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background 0.2s;
}

.token-list-item:hover { background: rgba(255,255,255,0.03); }

.token-list-item .token-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    color: var(--accent-primary);
}

.token-list-item .token-details { flex: 1; }
.token-list-item .token-name { font-weight: 500; font-size: 14px; }
.token-list-item .token-addr { font-size: 12px; color: var(--text-muted); font-family: monospace; }

.token-preview { margin-top: 16px; }

.badge {
    background: rgba(63, 185, 80, 0.15);
    color: var(--accent-green);
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.badge.verified {
    background: rgba(88, 166, 255, 0.15);
    color: var(--accent-primary);
}

/* Orders Table */
.orders-container .card { max-width: 900px; margin: 0 auto; }

.order-filters {
    display: flex;
    gap: 4px;
}

.filter-btn {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 4px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s;
}

.filter-btn.active, .filter-btn:hover {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
    background: rgba(88, 166, 255, 0.1);
}

.orders-table { overflow-x: auto; }

.orders-table table {
    width: 100%;
    border-collapse: collapse;
}

.orders-table th, .orders-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    font-size: 13px;
    white-space: nowrap;
}

.orders-table th {
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: 0.5px;
}

.status-badge {
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

.status-open { background: rgba(88, 166, 255, 0.15); color: var(--accent-primary); }
.status-filled { background: rgba(63, 185, 80, 0.15); color: var(--accent-green); }
.status-cancelled { background: rgba(139, 148, 158, 0.15); color: var(--text-secondary); }
.status-partially_filled { background: rgba(210, 153, 34, 0.15); color: var(--accent-yellow); }

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal.hidden { display: none; }

.modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    width: 420px;
    max-height: 80vh;
    overflow-y: auto;
    padding: 24px;
    box-shadow: var(--shadow-lg);
}

.modal-sm { width: 360px; }

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.modal-close {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 18px;
    padding: 4px;
}

.modal-search {
    position: relative;
    margin-bottom: 16px;
}

.modal-search i {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.modal-search input {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 12px 14px 12px 40px;
    border-radius: var(--radius-md);
    font-size: 14px;
    outline: none;
}

.common-tokens {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}

.common-token {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    padding: 6px 14px;
    border-radius: var(--radius-xl);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.common-token:hover { border-color: var(--accent-primary); color: var(--accent-primary); }

.modal-token-list { max-height: 300px; overflow-y: auto; }

/* Transaction Modal */
.tx-status {
    text-align: center;
    padding: 20px;
}

.spinner {
    width: 60px;
    height: 60px;
    border: 3px solid var(--border-color);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    margin: 0 auto 20px;
    animation: spin 1s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.tx-success-icon { font-size: 60px; color: var(--accent-green); margin-bottom: 16px; }
.tx-error-icon { font-size: 60px; color: var(--accent-red); margin-bottom: 16px; }
.tx-status h3 { margin-bottom: 12px; }
.tx-status .btn { margin-top: 12px; }

/* Toast */
.toast-container {
    position: fixed;
    top: 80px;
    right: 24px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 12px 20px;
    font-size: 14px;
    box-shadow: var(--shadow-lg);
    animation: slideIn 0.3s ease;
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 300px;
}

.toast.success { border-left: 3px solid var(--accent-green); }
.toast.error { border-left: 3px solid var(--accent-red); }
.toast.info { border-left: 3px solid var(--accent-primary); }

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
    font-size: 14px;
}

.hidden { display: none !important; }

/* Responsive */
@media (max-width: 768px) {
    .navbar {
        flex-direction: column;
        height: auto;
        padding: 12px;
        gap: 12px;
    }
    
    .nav-tabs {
        overflow-x: auto;
        width: 100%;
        justify-content: flex-start;
    }
    
    .nav-tab span { display: none; }
    
    .container { padding: 16px; }
    
    .modal-content { width: 95%; margin: 0 10px; }
    
    .orderbook-header, .orderbook-row {
        font-size: 11px;
    }
}
