/* webapp/styles.css */
/* Solar Wallet - Modern WebApp Styles */

:root {
    /* Colors */
    --bg-primary: #0a0e17;
    --bg-secondary: #111827;
    --bg-card: #1a2235;
    --bg-card-hover: #1f2940;
    --bg-input: #0d1320;
    
    --text-primary: #ffffff;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    
    --accent-primary: #10b981;
    --accent-primary-hover: #34d399;
    --accent-primary-glow: rgba(16, 185, 129, 0.3);
    
    --accent-secondary: #3b82f6;
    --accent-secondary-hover: #60a5fa;
    
    --accent-warning: #f59e0b;
    --accent-danger: #ef4444;
    --accent-purple: #8b5cf6;
    
    --border-color: #2d3748;
    --border-light: #374151;
    
    /* Gradients */
    --gradient-primary: linear-gradient(135deg, #10b981 0%, #059669 100%);
    --gradient-card: linear-gradient(180deg, rgba(26, 34, 53, 0.9) 0%, rgba(17, 24, 39, 0.95) 100%);
    --gradient-glow: radial-gradient(circle at center, rgba(16, 185, 129, 0.15) 0%, transparent 70%);
    
    /* Sizing */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-full: 9999px;
    
    /* Shadows */
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.4);
    --shadow-glow: 0 0 20px var(--accent-primary-glow);
    
    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s ease;
    --transition-slow: 0.4s ease;
}

/* Reset & Base */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* App Container */
.app-container {
    max-width: 480px;
    margin: 0 auto;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
    background: var(--bg-primary);
    background-image: var(--gradient-glow);
    background-attachment: fixed;
}

/* Header */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: rgba(17, 24, 39, 0.8);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.avatar {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-full);
    background: var(--gradient-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 18px;
    color: white;
    text-transform: uppercase;
    box-shadow: var(--shadow-glow);
}

.avatar.has-photo {
    background-size: cover;
    background-position: center;
}

.user-details {
    display: flex;
    flex-direction: column;
}

.user-name {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.3;
}

.user-id {
    font-size: 12px;
    color: var(--text-muted);
}

.refresh-btn {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition-fast);
}

.refresh-btn:hover {
    background: var(--bg-card-hover);
    color: var(--accent-primary);
    border-color: var(--accent-primary);
}

.refresh-btn:active {
    transform: scale(0.95);
}

.refresh-btn.spinning svg {
    animation: spin 1s linear infinite;
}

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

/* Balance Card */
.balance-card {
    margin: 20px;
    padding: 24px;
    background: var(--gradient-card);
    border-radius: var(--radius-xl);
    border: 1px solid var(--border-color);
    text-align: center;
    position: relative;
    overflow: hidden;
}

.balance-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 200px;
    height: 200px;
    background: radial-gradient(circle, rgba(16, 185, 129, 0.1) 0%, transparent 70%);
    pointer-events: none;
}

.balance-label {
    font-size: 13px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 8px;
}

.balance-amount {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 8px;
    margin-bottom: 16px;
}

.balance-value {
    font-size: 42px;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -1px;
}

.balance-currency {
    font-size: 18px;
    font-weight: 600;
    color: var(--accent-primary);
}

.balance-secondary {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
}

.tickets-info {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: rgba(139, 92, 246, 0.15);
    border-radius: var(--radius-full);
    border: 1px solid rgba(139, 92, 246, 0.3);
}

.ticket-icon {
    font-size: 14px;
}

.ticket-count {
    font-weight: 700;
    color: var(--accent-purple);
}

.ticket-label {
    font-size: 12px;
    color: var(--text-secondary);
}

.economy-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: rgba(16, 185, 129, 0.15);
    border-radius: var(--radius-full);
    border: 1px solid rgba(16, 185, 129, 0.3);
}

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

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

.economy-text {
    font-size: 12px;
    font-weight: 600;
    color: var(--accent-primary);
}

/* Quick Actions */
.quick-actions {
    display: flex;
    gap: 12px;
    padding: 0 20px;
    margin-bottom: 20px;
}

.action-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 16px 12px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition-normal);
}

.action-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.action-btn:active {
    transform: translateY(0);
}

.action-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
}

.action-send .action-icon {
    background: rgba(16, 185, 129, 0.15);
    color: var(--accent-primary);
}

.action-send:hover {
    border-color: var(--accent-primary);
    background: rgba(16, 185, 129, 0.05);
}

.action-receive .action-icon {
    background: rgba(59, 130, 246, 0.15);
    color: var(--accent-secondary);
}

.action-receive:hover {
    border-color: var(--accent-secondary);
    background: rgba(59, 130, 246, 0.05);
}

.action-crate .action-icon {
    background: rgba(245, 158, 11, 0.15);
}

.action-crate:hover {
    border-color: var(--accent-warning);
    background: rgba(245, 158, 11, 0.05);
}

/* Tab Navigation */
.tab-nav {
    display: flex;
    gap: 4px;
    padding: 4px;
    margin: 0 20px 16px;
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
}

.tab-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 10px 8px;
    background: transparent;
    border: none;
    border-radius: var(--radius-md);
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition-fast);
}

.tab-btn svg {
    width: 20px;
    height: 20px;
}

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

.tab-btn.active {
    background: var(--bg-card);
    color: var(--accent-primary);
    box-shadow: var(--shadow-sm);
}

/* Tab Content */
.tab-content {
    flex: 1;
    padding: 0 20px 100px;
}

.tab-panel {
    display: none;
    animation: fadeIn 0.3s ease;
}

.tab-panel.active {
    display: block;
}

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

/* Section Card */
.section-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 20px;
    margin-bottom: 16px;
}

.section-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.section-desc {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 16px;
    line-height: 1.6;
}

/* Tips List */
.tips-list {
    list-style: none;
}

.tips-list li {
    position: relative;
    padding-left: 20px;
    margin-bottom: 10px;
    font-size: 14px;
    color: var(--text-secondary);
}

.tips-list li::before {
    content: '•';
    position: absolute;
    left: 0;
    color: var(--accent-primary);
    font-weight: bold;
}

/* Economy Info */
.economy-info {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.economy-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-color);
}

.economy-row:last-child {
    border-bottom: none;
}

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

.economy-value {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

/* Commands Grid */
.commands-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.command-item {
    padding: 10px;
    background: var(--bg-input);
    border-radius: var(--radius-sm);
    text-align: center;
    font-size: 13px;
    font-family: 'SF Mono', Monaco, monospace;
    color: var(--accent-primary);
    border: 1px solid var(--border-color);
}

/* Form Elements */
.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-input {
    width: 100%;
    padding: 14px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 15px;
    font-family: inherit;
    transition: var(--transition-fast);
}

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

.form-input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px var(--accent-primary-glow);
}

.form-input:read-only {
    background: var(--bg-secondary);
    cursor: default;
}

.form-hint {
    display: block;
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 6px;
}

/* Amount Input */
.amount-input-wrapper {
    position: relative;
}

.amount-input {
    padding-right: 70px;
    font-size: 18px;
    font-weight: 600;
}

.amount-suffix {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 500;
}

.amount-presets {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}

.preset-btn {
    flex: 1;
    padding: 8px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition-fast);
}

.preset-btn:hover {
    background: var(--bg-card-hover);
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

/* Copy Field */
.copy-field {
    display: flex;
    gap: 8px;
}

.copy-field .form-input {
    flex: 1;
    font-size: 13px;
    font-family: 'SF Mono', Monaco, monospace;
}

.copy-btn {
    width: 48px;
    height: 48px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition-fast);
}

.copy-btn:hover {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    color: white;
}

.copy-btn:active {
    transform: scale(0.95);
}

/* Divider */
.divider {
    display: flex;
    align-items: center;
    gap: 16px;
    margin: 24px 0;
    color: var(--text-muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.divider::before,
.divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border-color);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 24px;
    border: none;
    border-radius: var(--radius-md);
    font-size: 15px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition-normal);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-full {
    width: 100%;
}

.btn-primary {
    background: var(--gradient-primary);
    color: white;
    box-shadow: var(--shadow-md), 0 0 20px var(--accent-primary-glow);
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg), 0 0 30px var(--accent-primary-glow);
}

.btn-primary:active:not(:disabled) {
    transform: translateY(0);
}

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

.btn-secondary:hover:not(:disabled) {
    background: var(--bg-card-hover);
    border-color: var(--text-muted);
}

.btn-crate {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: white;
    font-size: 16px;
    padding: 16px 24px;
    box-shadow: var(--shadow-md), 0 0 20px rgba(245, 158, 11, 0.3);
}

.btn-crate:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg), 0 0 30px rgba(245, 158, 11, 0.4);
}

/* Status Message */
.status-message {
    margin-top: 16px;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    font-size: 14px;
    text-align: center;
    display: none;
}

.status-message.show {
    display: block;
    animation: fadeIn 0.3s ease;
}

.status-message.success {
    background: rgba(16, 185, 129, 0.15);
    border: 1px solid rgba(16, 185, 129, 0.3);
    color: var(--accent-primary);
}

.status-message.error {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: var(--accent-danger);
}

.status-message.info {
    background: rgba(59, 130, 246, 0.15);
    border: 1px solid rgba(59, 130, 246, 0.3);
    color: var(--accent-secondary);
}

/* Crate Card */
.crate-card {
    text-align: center;
}

.crate-visual {
    position: relative;
    width: 120px;
    height: 120px;
    margin: 0 auto 20px;
}

.crate-box {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 64px;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.crate-box.opening {
    animation: shake 0.5s ease-in-out;
}

@keyframes shake {
    0%, 100% { transform: rotate(0); }
    25% { transform: rotate(-10deg); }
    75% { transform: rotate(10deg); }
}

.crate-glow {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 150px;
    height: 150px;
    background: radial-gradient(circle, rgba(245, 158, 11, 0.2) 0%, transparent 70%);
    pointer-events: none;
}

.crate-title {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.crate-desc {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 20px;
}

.crate-cost {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 12px;
}

.cost-label {
    color: var(--text-muted);
}

.cost-value {
    font-weight: 700;
    color: var(--accent-purple);
}

.crate-balance {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 20px;
    font-size: 14px;
    color: var(--text-secondary);
}

.tickets-highlight {
    font-weight: 700;
    color: var(--accent-purple);
}

.crate-rewards {
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

.crate-rewards h4 {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.reward-tiers {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.reward-tier {
    display: flex;
    justify-content: space-between;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    font-size: 13px;
}

.tier-name {
    font-weight: 600;
}

.tier-range {
    color: var(--text-secondary);
}

.tier-common {
    background: rgba(148, 163, 184, 0.1);
    border-left: 3px solid #94a3b8;
}

.tier-common .tier-name { color: #94a3b8; }

.tier-uncommon {
    background: rgba(34, 197, 94, 0.1);
    border-left: 3px solid #22c55e;
}

.tier-uncommon .tier-name { color: #22c55e; }

.tier-rare {
    background: rgba(59, 130, 246, 0.1);
    border-left: 3px solid #3b82f6;
}

.tier-rare .tier-name { color: #3b82f6; }

.tier-epic {
    background: rgba(139, 92, 246, 0.1);
    border-left: 3px solid #8b5cf6;
}

.tier-epic .tier-name { color: #8b5cf6; }

.tier-legendary {
    background: rgba(245, 158, 11, 0.1);
    border-left: 3px solid #f59e0b;
}

.tier-legendary .tier-name { color: #f59e0b; }

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(10, 14, 23, 0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition-normal);
}

.loading-overlay.show {
    opacity: 1;
    visibility: visible;
}

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

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

/* Toast */
.toast {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    padding: 12px 24px;
    box-shadow: var(--shadow-lg);
    z-index: 1001;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition-normal);
}

.toast.show {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

.toast.success {
    border-color: var(--accent-primary);
}

.toast.error {
    border-color: var(--accent-danger);
}

.toast-message {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Mobile Adjustments */
@media (max-width: 380px) {
    .balance-value {
        font-size: 36px;
    }
    
    .quick-actions {
        gap: 8px;
    }
    
    .action-btn {
        padding: 12px 8px;
    }
    
    .action-icon {
        width: 40px;
        height: 40px;
    }
    
    .commands-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Safe Area for iOS */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    .tab-content {
        padding-bottom: calc(100px + env(safe-area-inset-bottom));
    }
}

/* Dark mode adjustments for Telegram */
@media (prefers-color-scheme: dark) {
    :root {
        color-scheme: dark;
    }
}

/* Haptic feedback simulation */
.btn:active,
.action-btn:active,
.tab-btn:active,
.preset-btn:active,
.copy-btn:active {
    transform: scale(0.97);
}