/* Main Application Styles - Extracted & Modernized */

/* Base Layout & Transitions */
html,
body {
    height: 100%;
    margin: 0;
    overflow: hidden;
}

body {
    background-color: var(--background);
    /* Subtle Mesh Gradient Background for Premium Feel */
    background-image:
        radial-gradient(circle at 0% 0%, rgba(0, 122, 255, 0.03) 0%, transparent 50%),
        radial-gradient(circle at 100% 100%, rgba(255, 45, 85, 0.03) 0%, transparent 50%);
    background-attachment: fixed;
    color: var(--text-main);
    padding-bottom: var(--safe-bottom);
    opacity: 0;
    transition: opacity 0.4s ease-out;
}

body.app-ready {
    opacity: 1;
}

#app {
    height: 100%;
}

.main-container {
    padding-top: 6rem;
}

@media (max-width: 768px) {
    .main-container {
        padding-top: 13rem;
    }
}

[v-cloak] {
    display: none;
}

/* Components: Header */
.glass-header {
    background: var(--surface-glass-strong);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
    z-index: 800;
    padding-top: var(--safe-top);
    box-shadow: var(--shadow-sm);
}

/* Components: Cards (The Core Grid) */
.ios-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    position: relative;
    display: flex;
    flex-direction: column;
    height: 100%;
    border: 1px solid var(--border);
    z-index: 1;
    overflow: hidden;
}

.ios-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-xl);
    z-index: 20;
    border-color: rgba(0, 122, 255, 0.3);
}

.ios-card:active {
    transform: scale(0.98);
}

.card-grid {
    align-items: stretch;
    position: relative;
    z-index: 1;
}

.input-panel {
    position: relative;
    z-index: 30;
}

.history-dropdown {
    z-index: 300;
}

/* Loaders */
.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-left-color: #fff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    100% {
        transform: rotate(360deg);
    }
}

/* Modal System (Price Chart) */
.price-chart-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(12px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: fadeIn 0.3s ease;
}

.price-chart-modal.hidden {
    display: none;
}

.price-chart-content-enhanced {
    background: var(--surface);
    border-radius: var(--radius-xl);
    max-width: 900px;
    width: 100%;
    max-height: 90vh;
    overflow: hidden;
    box-shadow: var(--shadow-xl);
    animation: slideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    flex-direction: column;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(40px) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.chart-header {
    padding: 28px 32px 24px;
    background: linear-gradient(135deg, rgba(0, 122, 255, 0.05) 0%, rgba(88, 86, 214, 0.03) 100%);
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    position: relative;
}

.chart-header::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 32px;
    right: 32px;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(0, 122, 255, 0.3), transparent);
}

.chart-thumbnail {
    width: 72px;
    height: 100px;
    background: white;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    overflow: hidden;
    flex-shrink: 0;
    border: 1px solid var(--border);
}

.close-btn {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    background: rgba(255, 59, 48, 0.1);
    /* Apple Red Light */
    color: #FF3B30;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    cursor: pointer;
    flex-shrink: 0;
}

.close-btn:hover {
    background: #FF3B30;
    color: white;
    transform: rotate(90deg);
}

.chart-content {
    flex: 1;
    overflow-y: auto;
    padding: 28px 32px;
}

/* Scrollbar Styling */
.chart-content::-webkit-scrollbar,
.custom-scrollbar::-webkit-scrollbar,
.sidebar-list::-webkit-scrollbar {
    width: 6px;
}

.chart-content::-webkit-scrollbar-track,
.custom-scrollbar::-webkit-scrollbar-track,
.sidebar-list::-webkit-scrollbar-track {
    background: transparent;
}

.chart-content::-webkit-scrollbar-thumb,
.custom-scrollbar::-webkit-scrollbar-thumb,
.sidebar-list::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 3px;
}

.chart-content::-webkit-scrollbar-thumb:hover,
.custom-scrollbar::-webkit-scrollbar-thumb:hover,
.sidebar-list::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.2);
}

/* States */
.chart-loading,
.chart-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 20px;
    text-align: center;
    color: var(--text-secondary);
}

.spinner-enhanced {
    width: 48px;
    height: 48px;
    border: 4px solid rgba(0, 122, 255, 0.1);
    border-left-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.empty-icon {
    width: 80px;
    height: 80px;
    background: var(--background);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 20px;
    animation: float 3s ease-in-out infinite;
}

.empty-icon i {
    font-size: 36px;
    color: var(--text-secondary);
}

@keyframes float {

    0%,
    100% {
        transform: translateY(0px);
    }

    50% {
        transform: translateY(-10px);
    }
}

/* Stats Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

@media (max-width: 640px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
}

.stat-card {
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 18px;
    display: flex;
    gap: 14px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--primary-gradient);
    transform: scaleX(0);
    transition: transform 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
    border-color: rgba(0, 122, 255, 0.3);
}

.stat-card:hover::before {
    transform: scaleX(1);
}

.stat-primary {
    background: linear-gradient(135deg, #f0f7ff 0%, #ffffff 100%);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    background: var(--primary-gradient);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(0, 122, 255, 0.2);
}

.stat-icon-green {
    background: linear-gradient(135deg, #34C759 0%, #30B34F 100%);
    box-shadow: 0 4px 12px rgba(52, 199, 89, 0.2);
}

.stat-icon-red {
    background: var(--secondary-gradient);
    box-shadow: 0 4px 12px rgba(255, 45, 85, 0.2);
}

.stat-content {
    flex: 1;
    min-width: 0;
}

.stat-label {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.stat-value {
    font-size: 24px;
    font-weight: 800;
    color: var(--text-main);
    line-height: 1.2;
    margin-bottom: 4px;
}

.stat-change,
.stat-meta {
    font-size: 13px;
    font-weight: 600;
}

.stat-change.trend-up {
    color: #FF3B30;
}

.stat-change.trend-down {
    color: #34C759;
}

.stat-change.trend-flat {
    color: var(--text-secondary);
}

.stat-meta {
    color: var(--text-secondary);
}

/* Controls */
.time-range-selector {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    background: rgba(0, 0, 0, 0.03);
    padding: 6px;
    border-radius: 14px;
    width: fit-content;
}

.range-btn {
    padding: 8px 20px;
    border-radius: 10px;
    background: transparent;
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 14px;
    transition: all 0.3s;
    border: none;
    cursor: pointer;
}

.range-btn:hover {
    color: var(--primary);
    background: rgba(255, 255, 255, 0.5);
}

.range-btn.active {
    background: white;
    color: var(--primary);
    box-shadow: var(--shadow-sm);
}

.chart-container {
    background: linear-gradient(135deg, #fafafa 0%, #ffffff 100%);
    border-radius: 20px;
    padding: 24px;
    margin-bottom: 20px;
    border: 1px solid var(--border);
    position: relative;
}

.chart-summary {
    display: flex;
    gap: 24px;
    flex-wrap: wrap;
    padding: 20px;
    background: #FAFAFA;
    border-radius: 14px;
    border: 1px solid var(--border);
}

.summary-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
}

.trend-up {
    color: #FF3B30;
}

.trend-down {
    color: #34C759;
}

.trend-flat {
    color: var(--text-secondary);
}

/* Action Buttons (Hover on card) */
.action-btn {
    position: absolute;
    z-index: 30;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(0, 0, 0, 0.1);
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    opacity: 0;
    transform: scale(0.9);
    box-shadow: var(--shadow-sm);
}

.trend-button {
    top: 8px;
    left: 8px;
    color: var(--text-secondary);
}

.favorite-button {
    top: 8px;
    right: 8px;
    color: var(--text-secondary);
}

.cart-btn-inline {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #f3f4f6;
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    cursor: pointer;
    margin-left: 8px;
    flex-shrink: 0;
}

.cart-btn-inline:hover {
    background: #dbeafe;
    transform: scale(1.05);
}

.cart-btn-inline:active {
    transform: scale(0.95);
}

.cart-btn-inline.in-cart {
    background: var(--primary);
    color: white;
}

.is-processing {
    opacity: 0.7 !important;
    cursor: not-allowed !important;
    pointer-events: none !important;
}

.ios-card:hover .action-btn {
    opacity: 1;
    transform: scale(1);
}

.action-btn:hover {
    background: white;
    transform: scale(1.1) !important;
    box-shadow: var(--shadow-md);
}

@media (max-width: 768px) {
    .action-btn {
        opacity: 1 !important;
        transform: scale(1) !important;
        width: 32px;
        height: 32px;
    }
}

.trend-button.has-data {
    color: var(--primary);
    background: rgba(0, 122, 255, 0.1);
}

.favorite-button.is-favorite {
    opacity: 1;
    color: #FF3B30;
    background: rgba(255, 59, 48, 0.1);
}

/* Sidebar (Glassmorphism Upgrade) */
.sidebar-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: 400px;
    height: 100vh;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    box-shadow: var(--shadow-xl);
    z-index: 900;
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    transform: translateX(100%);
    will-change: transform;
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding-bottom: var(--safe-bottom);
}

@media (max-width: 768px) {
    .sidebar-panel {
        width: 100%;
        transform: translateX(100%);
    }
}

.sidebar-panel.open {
    transform: translateX(0);
}

.sidebar-header {
    padding: 24px 24px 20px;
    padding-top: max(24px, var(--safe-top));
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.8) 0%, rgba(249, 250, 251, 0.8) 100%);
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sidebar-header h2 {
    font-size: 20px;
    font-weight: 800;
    letter-spacing: -0.5px;
}

.sidebar-list {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    padding-bottom: calc(180px + var(--safe-bottom));
}

.sidebar-card {
    background: white;
    border-radius: 16px;
    padding: 12px;
    display: flex;
    gap: 12px;
    margin-bottom: 12px;
    border: 1px solid var(--border);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--shadow-sm);
}

.sidebar-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: rgba(0, 122, 255, 0.3);
}

.sidebar-card-img {
    width: 72px;
    height: 72px;
    border-radius: 12px;
    object-fit: contain;
    background: #f8fafc;
    padding: 4px;
    border: 1px solid var(--border);
}

.sidebar-card-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.sidebar-card-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 4px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.sidebar-tag {
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 600;
    background: #f3f4f6;
    color: var(--text-secondary);
}

.sidebar-footer-fixed {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(20px);
    border-top: 1px solid var(--border);
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.05);
    z-index: 50;
    padding: 20px;
    padding-bottom: max(20px, env(safe-area-inset-bottom));
}

@media (max-width: 768px) {
    .sidebar-footer-fixed {
        padding-bottom: max(80px, calc(80px + env(safe-area-inset-bottom)));
        /* Lift button above mobile nav bars */
    }

    .sidebar-list {
        padding-bottom: calc(240px + env(safe-area-inset-bottom));
        /* Ensure list content isn't hidden behind taller footer */
    }
}

/* Toast */

.toast-container {
    position: fixed;
    top: max(20px, env(safe-area-inset-top));
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
    width: 90%;
    max-width: 400px;
}

.toast {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(12px);
    padding: 12px 24px;
    border-radius: 50px;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-main);
    pointer-events: auto;
    min-width: 300px;
    border: 1px solid rgba(255, 255, 255, 0.5);
    animation: slideDownToast 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    transition: transform 0.2s ease-out, opacity 0.2s ease-out;
}

@keyframes slideDownToast {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.toast.success {
    border-left: 4px solid #34C759;
}

.toast.error {
    border-left: 4px solid #FF3B30;
}

.toast.info {
    border-left: 4px solid var(--primary);
}

.toast i.success-icon {
    color: #34C759;
}

.toast i.error-icon {
    color: #FF3B30;
}

/* Empty States */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 20px;
    border: 2px dashed rgba(0, 0, 0, 0.1);
    margin: 20px;
}

/* Price Modal Compact */
.price-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(8px);
    z-index: 9000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.price-modal-card {
    background: white;
    border-radius: 20px;
    width: 100%;
    max-width: 580px;
    max-height: 90vh;
    overflow: hidden;
    box-shadow: var(--shadow-xl);
    animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.price-hero {
    background: var(--primary-gradient);
    border-radius: 12px;
    color: white;
    padding: 16px;
    margin-bottom: 16px;
}