/* Gold Price Chart Plugin - Enhanced UI/UX Styles */
@font-face {
    font-family: 'IRANSansX';
    src: url('https://wallgold.ir/blog/wp-content/uploads/2025/08/IRANSansXV.woff2') format('woff2');
    font-weight: 100 900;
    font-style: normal;
    font-display: swap;
}

/* Add box-sizing for better mobile control */
*, *::before, *::after {
    box-sizing: border-box;
}

.gold-price-chart-container {
    border: none;
    border-radius: 20px;
    background: linear-gradient(145deg, #ffffff 0%, #f8fafc 50%, #f1f5f9 100%);
    padding: 24px;
    font-family: 'IRANSansX', 'Tahoma', sans-serif;
    box-shadow: 
        0 20px 25px -5px rgba(0, 0, 0, 0.1),
        0 10px 10px -5px rgba(0, 0, 0, 0.04),
        inset 0 1px 0 rgba(255, 255, 255, 0.6);
    position: relative;
    direction: rtl;
    text-align: right;
    overflow: hidden;
    transition: all 0.3s ease;
    width: 100%;
    max-width: 100%;
    min-height: 400px;
}

.gold-price-chart-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #FFD700 0%, #FFA500 50%, #FF8C00 100%);
    border-radius: 20px 20px 0 0;
}

.gold-price-chart-container:hover {
    transform: translateY(-2px);
    box-shadow: 
        0 25px 50px -12px rgba(0, 0, 0, 0.15),
        0 20px 25px -5px rgba(0, 0, 0, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

/* Notification System */
.chart-notification {
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 500;
    z-index: 1000;
    display: flex;
    align-items: center;
    gap: 6px;
    animation: slideInDown 0.3s ease;
    max-width: calc(100% - 20px);
    word-wrap: break-word;
}

.chart-notification.success {
    background: linear-gradient(135deg, #10B981, #059669);
    color: white;
    box-shadow: 0 4px 6px rgba(16, 185, 129, 0.3);
}

.chart-notification.error {
    background: linear-gradient(135deg, #EF4444, #DC2626);
    color: white;
    box-shadow: 0 4px 6px rgba(239, 68, 68, 0.3);
}

@keyframes slideInDown {
    from {
        opacity: 0;
        transform: translate(-50%, -10px);
    }
    to {
        opacity: 1;
        transform: translate(-50%, 0);
    }
}

/* Enhanced Header */
.chart-header {
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 2px solid rgba(255, 215, 0, 0.2);
    position: relative;
}

.chart-header::after {
    content: '';
    position: absolute;
    bottom: -2px;
    right: 0;
    width: 60px;
    height: 2px;
    background: linear-gradient(90deg, #FFD700, #FFA500);
    border-radius: 1px;
}

.chart-title {
    font-size: 20px;
    font-weight: 700;
    color: #1F2937;
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    line-height: 1.4;
    flex-wrap: wrap;
    gap: 10px;
}

.current-price {
    font-size: 16px;
    font-weight: 600;
    padding: 8px 12px;
    border-radius: 10px;
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.1), rgba(255, 165, 0, 0.05));
    border: 1px solid rgba(255, 215, 0, 0.3);
    transition: all 0.3s ease;
    white-space: nowrap;
}

.current-price:hover {
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.2), rgba(255, 165, 0, 0.1));
    transform: scale(1.02);
}

/* Enhanced Button Design */
.chart-buttons {
    display: flex;
    gap: 6px;
    margin-bottom: 20px;
    justify-content: center;
    background: rgba(248, 250, 252, 0.8);
    padding: 6px;
    border-radius: 14px;
    border: 1px solid rgba(226, 232, 240, 0.6);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.chart-btn {
    padding: 10px 20px;
    border: none;
    background: transparent;
    border-radius: 10px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    color: #64748B;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-family: inherit;
    position: relative;
    overflow: hidden;
    white-space: nowrap;
    flex-shrink: 0;
}

.chart-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #FFD700, #FFA500);
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: -1;
}

.chart-btn:hover:not(.active):not(:disabled) {
    color: #374151;
    background: rgba(255, 255, 255, 0.8);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.chart-btn.hovered {
    transform: translateY(-1px);
    background: rgba(255, 255, 255, 0.9);
}

.chart-btn.clicked {
    transform: scale(0.95);
}

.chart-btn.active {
    background: linear-gradient(135deg, #FFD700, #FFA500);
    color: #1F2937;
    font-weight: 700;
    box-shadow: 
        0 4px 12px rgba(255, 215, 0, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.chart-btn.active::before {
    opacity: 1;
}

.chart-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Enhanced Chart Container */
.chart-canvas-container {
    position: relative;
    background: linear-gradient(135deg, #ffffff 0%, #fefefe 100%);
    border-radius: 16px;
    padding: 20px;
    border: 1px solid rgba(226, 232, 240, 0.8);
    margin-bottom: 20px;
    transition: all 0.3s ease;
    overflow: hidden;
    min-height: 250px;
}

.chart-canvas-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(circle at 30% 20%, rgba(255, 215, 0, 0.05), transparent 50%),
                radial-gradient(circle at 80% 80%, rgba(255, 165, 0, 0.05), transparent 50%);
    pointer-events: none;
}

.chart-canvas-container.loading {
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
}

#goldPriceChart {
    width: 100% !important;
    height: 300px !important;
    position: relative;
    z-index: 1;
}

/* Enhanced Loading Animation */
.chart-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 255, 255, 0.95);
    padding: 20px 30px;
    border-radius: 12px;
    font-weight: 600;
    color: #374151;
    display: none;
    z-index: 10;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    text-align: center;
}

.loading-spinner {
    width: 24px;
    height: 24px;
    border: 3px solid #E5E7EB;
    border-top: 3px solid #FFD700;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 10px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Enhanced Footer */
.chart-footer {
    text-align: center;
    padding-top: 8px;
}

.buy-gold-btn {
    display: inline-block;
    background: linear-gradient(135deg, #FFD700 0%, #FFA500 50%, #FF8C00 100%);
    color: #1F2937;
    text-decoration: none;
    padding: 14px 28px;
    border-radius: 12px;
    font-weight: 700;
    font-size: 14px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 
        0 4px 15px rgba(255, 215, 0, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.3);
    position: relative;
    overflow: hidden;
    max-width: 100%;
    word-wrap: break-word;
}

.buy-gold-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    transition: left 0.6s;
}

.buy-gold-btn:hover {
    background: linear-gradient(135deg, #FFA500 0%, #FF8C00 50%, #FF7F00 100%);
    color: #1F2937;
    text-decoration: none;
    box-shadow: 
        0 6px 20px rgba(255, 165, 0, 0.5),
        inset 0 1px 0 rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
}

.buy-gold-btn:hover::before {
    left: 100%;
}

.buy-gold-btn:active {
    transform: translateY(0);
    box-shadow: 
        0 2px 10px rgba(255, 165, 0, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

/* Improved Mobile Responsive Design */
@media (max-width: 768px) {
    .gold-price-chart-container {
        padding: 16px;
        border-radius: 16px;
        min-height: auto;
    }
    
    .chart-header {
        margin-bottom: 15px;
        padding-bottom: 15px;
    }
    
    .chart-title {
        font-size: 16px;
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
        text-align: center;
    }
    
    .current-price {
        font-size: 14px;
        padding: 6px 10px;
        width: 100%;
        text-align: center;
    }
    
    .chart-buttons {
        gap: 4px;
        padding: 4px;
        margin-bottom: 15px;
        border-radius: 10px;
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;
    }
    
    .chart-buttons::-webkit-scrollbar {
        height: 4px;
    }
    
    .chart-buttons::-webkit-scrollbar-track {
        background: rgba(0, 0, 0, 0.05);
        border-radius: 2px;
    }
    
    .chart-buttons::-webkit-scrollbar-thumb {
        background: rgba(255, 215, 0, 0.5);
        border-radius: 2px;
    }
    
    .chart-btn {
        padding: 8px 16px;
        font-size: 13px;
        border-radius: 8px;
        flex: 0 0 auto;
        min-width: auto;
    }
    
    .chart-canvas-container {
        padding: 12px;
        border-radius: 12px;
        margin-bottom: 15px;
        min-height: 200px;
    }
    
    #goldPriceChart {
        height: 250px !important;
    }
    
    .chart-loading {
        padding: 15px 20px;
        font-size: 14px;
    }
    
    .buy-gold-btn {
        padding: 12px 24px;
        font-size: 13px;
        border-radius: 10px;
        width: 100%;
        max-width: 300px;
    }
}

@media (max-width: 480px) {
    .gold-price-chart-container {
        padding: 12px;
        border-radius: 12px;
        min-height: auto;
    }
    
    .chart-header {
        margin-bottom: 12px;
        padding-bottom: 12px;
    }
    
    .chart-title {
        font-size: 14px;
        flex-direction: column;
        gap: 6px;
    }
    
    .current-price {
        font-size: 13px;
        padding: 5px 8px;
        border-radius: 8px;
    }
    
    .chart-buttons {
        gap: 3px;
        padding: 3px;
        margin-bottom: 12px;
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        overflow-x: visible;
    }
    
    .chart-btn {
        padding: 7px 12px;
        font-size: 12px;
        border-radius: 6px;
        width: 100%;
    }
    
    .chart-canvas-container {
        padding: 10px;
        border-radius: 10px;
        margin-bottom: 12px;
        min-height: 180px;
    }
    
    #goldPriceChart {
        height: 200px !important;
    }
    
    .chart-loading {
        padding: 12px 16px;
        font-size: 13px;
        border-radius: 8px;
    }
    
    .loading-spinner {
        width: 20px;
        height: 20px;
        border-width: 2px;
        margin-bottom: 8px;
    }
    
    .buy-gold-btn {
        padding: 10px 20px;
        font-size: 12px;
        border-radius: 8px;
        width: 100%;
        max-width: none;
    }
    
    .chart-notification {
        padding: 6px 12px;
        font-size: 11px;
        max-width: calc(100% - 24px);
    }
}

/* Extra small devices */
@media (max-width: 360px) {
    .gold-price-chart-container {
        padding: 10px;
        border-radius: 10px;
    }
    
    .chart-header {
        margin-bottom: 10px;
        padding-bottom: 10px;
    }
    
    .chart-title {
        font-size: 13px;
    }
    
    .current-price {
        font-size: 12px;
        padding: 4px 6px;
    }
    
    .chart-buttons {
        gap: 2px;
        padding: 2px;
    }
    
    .chart-btn {
        padding: 6px 10px;
        font-size: 11px;
    }
    
    .chart-canvas-container {
        padding: 8px;
        min-height: 160px;
    }
    
    #goldPriceChart {
        height: 180px !important;
    }
    
    .buy-gold-btn {
        padding: 8px 16px;
        font-size: 11px;
    }
}

/* Landscape mode adjustments */
@media (max-height: 600px) and (orientation: landscape) {
    .gold-price-chart-container {
        min-height: auto;
    }
    
    #goldPriceChart {
        height: 150px !important;
    }
    
    .chart-canvas-container {
        min-height: 150px;
    }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    .chart-btn {
        min-height: 44px;
        min-width: 44px;
    }
    
    .buy-gold-btn {
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .chart-btn:hover {
        transform: none;
        box-shadow: none;
    }
    
    .gold-price-chart-container:hover {
        transform: none;
    }
}

/* RTL specific enhancements */
.gold-price-chart-container * {
    font-family: 'IRANSansX', 'Tahoma', 'Arial', sans-serif;
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .gold-price-chart-container {
        background: linear-gradient(145deg, #1f2937 0%, #111827 50%, #0f172a 100%);
        border: 1px solid rgba(255, 215, 0, 0.2);
    }
    
    .chart-title {
        color: #F9FAFB;
    }
    
    .chart-buttons {
        background: rgba(31, 41, 55, 0.8);
        border-color: rgba(75, 85, 99, 0.6);
    }
    
    .chart-btn {
        color: #D1D5DB;
    }
    
    .chart-canvas-container {
        background: linear-gradient(135deg, #374151 0%, #2d3748 100%);
        border-color: rgba(75, 85, 99, 0.8);
    }
}

/* Price trend colors */
.price-positive {
    color: #10B981 !important;
}

.price-negative {
    color: #EF4444 !important;
}

/* Accessibility enhancements */
.chart-btn:focus {
    outline: 2px solid #FFD700;
    outline-offset: 2px;
}

.buy-gold-btn:focus {
    outline: 2px solid #FFD700;
    outline-offset: 3px;
}

/* Animation for price updates */
@keyframes priceUpdate {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
    100% {
        transform: scale(1);
    }
}

.current-price.updating {
    animation: priceUpdate 0.6s ease;
}

/* Prevent horizontal scroll on mobile */
html, body {
    overflow-x: hidden;
}

/* Ensure proper rendering on iOS devices */
@supports (-webkit-touch-callout: none) {
    .gold-price-chart-container {
        -webkit-transform: translateZ(0);
        transform: translateZ(0);
    }
}