:root {
    /* Light Theme */
    --bg-primary: rgba(255, 255, 255, 0.85);
    --bg-secondary: rgba(245, 247, 250, 0.9);
    --text-primary: #1a1a2e;
    --text-secondary: #4a5568;
    --border-color: rgba(0, 0, 0, 0.1);
    --accent-primary: #6366f1;
    --accent-secondary: #8b5cf6;
    --glass-bg: rgba(255, 255, 255, 0.2);
    --glass-border: rgba(255, 255, 255, 0.3);
    --shadow-sm: 0 8px 32px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.2);
    --card-bg: rgba(255, 255, 255, 0.7);
    --hover-bg: rgba(0, 0, 0, 0.05);
    --result-bg: rgba(255, 255, 255, 0.6);
}

[data-theme="dark"] {
    --bg-primary: rgba(10, 10, 25, 0.9);
    --bg-secondary: rgba(20, 20, 40, 0.95);
    --text-primary: #f0f0f0;
    --text-secondary: #a0a0b0;
    --border-color: rgba(255, 255, 255, 0.1);
    --accent-primary: #818cf8;
    --accent-secondary: #a78bfa;
    --glass-bg: rgba(0, 0, 0, 0.3);
    --glass-border: rgba(255, 255, 255, 0.1);
    --shadow-sm: 0 8px 32px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.4);
    --card-bg: rgba(30, 30, 50, 0.7);
    --hover-bg: rgba(255, 255, 255, 0.1);
    --result-bg: rgba(30, 30, 50, 0.6);
}

[data-theme="glass"] {
    --bg-primary: rgba(255, 255, 255, 0.2);
    --bg-secondary: rgba(255, 255, 255, 0.15);
    --text-primary: #ffffff;
    --text-secondary: #e0e0e0;
    --border-color: rgba(255, 255, 255, 0.2);
    --accent-primary: #a855f7;
    --accent-secondary: #d946ef;
    --glass-bg: rgba(0, 0, 0, 0.2);
    --glass-border: rgba(255, 255, 255, 0.25);
    --shadow-sm: 0 8px 32px rgba(0, 0, 0, 0.2);
    --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.3);
    --card-bg: rgba(255, 255, 255, 0.15);
    --hover-bg: rgba(255, 255, 255, 0.2);
    --result-bg: rgba(0, 0, 0, 0.3);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', 'Vazirmatn', system-ui, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    direction: rtl;
    overflow-x: hidden;
    position: relative;
}

/* Glass Background Effects */
.glass-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    animation: floatBg 20s ease-in-out infinite;
}

.gradient-1 { background: radial-gradient(circle at 20% 80%, rgba(120, 119, 198, 0.4) 0%, transparent 50%); }
.gradient-2 { background: radial-gradient(circle at 80% 20%, rgba(255, 119, 119, 0.4) 0%, transparent 50%); animation-delay: -5s; }
.gradient-3 { background: radial-gradient(circle at 40% 40%, rgba(119, 255, 190, 0.3) 0%, transparent 50%); animation-delay: -10s; }
.gradient-4 { background: radial-gradient(circle at 60% 70%, rgba(255, 255, 119, 0.3) 0%, transparent 50%); animation-delay: -15s; }

@keyframes floatBg {
    0%, 100% { transform: translate(0, 0) scale(1); opacity: 0.6; }
    50% { transform: translate(20px, -20px) scale(1.1); opacity: 0.8; }
}

.app-container {
    display: flex;
    min-height: 100vh;
    position: relative;
    z-index: 1;
    backdrop-filter: blur(8px);
}

/* Sidebar */
.sidebar {
    width: 280px;
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    border-left: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
    z-index: 10;
}

.sidebar-header {
    padding: 24px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    cursor: pointer;
}

.logo i {
    font-size: 1.75rem;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    background-clip: text;
    -webkit-background-clip: text;
    color: transparent;
}

.new-search-btn {
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    border: none;
    color: white;
    padding: 8px 12px;
    border-radius: 40px;
    cursor: pointer;
    font-size: 0.875rem;
    transition: transform 0.2s;
}

.new-search-btn:hover { transform: scale(1.05); }

.search-tools {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.tool-section h4 {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.history-list, .bookmark-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 200px;
    overflow-y: auto;
}

.history-item, .bookmark-item {
    background: var(--card-bg);
    padding: 8px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.history-item:hover, .bookmark-item:hover {
    background: var(--hover-bg);
    transform: translateX(-4px);
}

.history-item .delete-history, .bookmark-item .delete-bookmark {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s;
}

.history-item:hover .delete-history, .bookmark-item:hover .delete-bookmark {
    opacity: 1;
}

.quick-note {
    width: 100%;
    min-height: 100px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 10px;
    color: var(--text-primary);
    font-family: inherit;
    resize: vertical;
}

.sidebar-footer {
    padding: 20px;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 8px;
}

.theme-toggle, .clear-history, .settings-btn {
    flex: 1;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    padding: 10px;
    border-radius: 12px;
    cursor: pointer;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s;
}

.theme-toggle:hover, .clear-history:hover, .settings-btn:hover {
    background: var(--accent-primary);
    color: white;
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

/* Top Bar */
.top-bar {
    padding: 16px 24px;
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--glass-border);
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.menu-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-primary);
}

.search-tabs {
    display: flex;
    gap: 4px;
    background: var(--card-bg);
    padding: 4px;
    border-radius: 60px;
}

.tab-btn {
    background: none;
    border: none;
    padding: 8px 20px;
    border-radius: 40px;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.2s;
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.tab-btn.active {
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    color: white;
}

.view-options {
    display: flex;
    gap: 4px;
    background: var(--card-bg);
    padding: 4px;
    border-radius: 40px;
}

.view-btn {
    background: none;
    border: none;
    padding: 6px 12px;
    border-radius: 30px;
    cursor: pointer;
    color: var(--text-secondary);
}

.view-btn.active {
    background: var(--accent-primary);
    color: white;
}

.mic-btn {
    background: var(--card-bg);
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    color: var(--text-primary);
}

/* Hero Section */
.hero-section {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 60px 24px;
    transition: all 0.5s ease;
}

.hero-section.results-hidden {
    padding: 20px 24px;
}

.hero-glass {
    max-width: 800px;
    width: 100%;
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    border-radius: 48px;
    padding: 48px 32px;
    border: 1px solid var(--glass-border);
    box-shadow: var(--shadow-lg);
    animation: fadeInUp 0.6s ease;
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(30px); }
    to { opacity: 1; transform: translateY(0); }
}

.hero-icon {
    text-align: center;
    font-size: 4rem;
    margin-bottom: 16px;
}

.hero-title {
    text-align: center;
    font-size: 2.5rem;
    margin-bottom: 12px;
}

.gradient-text {
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    background-clip: text;
    -webkit-background-clip: text;
    color: transparent;
}

.hero-subtitle {
    text-align: center;
    color: var(--text-secondary);
    margin-bottom: 32px;
}

/* Search Container */
.search-container {
    margin-bottom: 24px;
}

.search-box {
    position: relative;
    margin-bottom: 20px;
}

.search-box input {
    width: 100%;
    padding: 18px 50px 18px 60px;
    font-size: 1rem;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 60px;
    color: var(--text-primary);
    backdrop-filter: blur(10px);
}

.search-box input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.search-icon {
    position: absolute;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
}

.search-submit {
    position: absolute;
    left: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    border: none;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    cursor: pointer;
    color: white;
}

.clear-search {
    position: absolute;
    left: 65px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
}

.search-filters {
    display: flex;
    gap: 16px;
    justify-content: center;
    flex-wrap: wrap;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--card-bg);
    padding: 8px 12px;
    border-radius: 40px;
}

.filter-group label {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.filter-group select {
    background: var(--bg-primary);
    border: none;
    color: var(--text-primary);
    padding: 4px 8px;
    border-radius: 20px;
    font-size: 0.8rem;
}

/* Example Searches */
.example-searches {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
    align-items: center;
}

.example-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.example-btn {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    padding: 6px 14px;
    border-radius: 40px;
    font-size: 0.8rem;
    cursor: pointer;
    color: var(--text-primary);
    transition: all 0.2s;
}

.example-btn:hover {
    background: var(--accent-primary);
    color: white;
    border-color: transparent;
}

/* Voice Status */
.voice-status {
    text-align: center;
    margin-top: 20px;
    padding: 12px;
    background: var(--card-bg);
    border-radius: 60px;
    color: var(--accent-primary);
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1; }
}

/* Results Section */
.results-section {
    flex: 1;
    padding: 24px;
    overflow-y: auto;
    animation: fadeIn 0.4s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 16px;
}

.results-count {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.results-sort {
    display: flex;
    align-items: center;
    gap: 8px;
}

.results-sort select {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    padding: 6px 12px;
    border-radius: 20px;
    color: var(--text-primary);
}

/* Result Cards */
.results-container.list .result-card {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 20px;
    background: var(--result-bg);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    margin-bottom: 16px;
    transition: all 0.2s;
}

.results-container.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 20px;
}

.results-container.grid .result-card {
    background: var(--result-bg);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 20px;
}

.results-container.card {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.results-container.card .result-card {
    background: var(--result-bg);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 24px;
    display: flex;
    gap: 16px;
    align-items: flex-start;
}

.results-container.card .result-card .result-icon {
    font-size: 2rem;
    flex-shrink: 0;
}

.result-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
    border-color: var(--accent-primary);
}

.result-title {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 8px;
}

.result-title a {
    color: var(--accent-primary);
    text-decoration: none;
}

.result-title a:hover {
    text-decoration: underline;
}

.result-url {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
    word-break: break-all;
}

.result-snippet {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.result-actions {
    display: flex;
    gap: 12px;
    margin-top: 12px;
}

.result-actions button {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.75rem;
    display: flex;
    align-items: center;
    gap: 4px;
}

.result-actions button:hover {
    color: var(--accent-primary);
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 32px;
    flex-wrap: wrap;
}

.pagination button {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    padding: 8px 14px;
    border-radius: 8px;
    cursor: pointer;
    color: var(--text-primary);
}

.pagination button.active {
    background: var(--accent-primary);
    color: white;
    border-color: transparent;
}

/* Tools Section */
.tools-section {
    padding: 24px;
}

.tools-grid {
    display: flex;
    gap: 16px;
    justify-content: center;
    margin-bottom: 24px;
}

.tool-card {
    background: var(--card-bg);
    backdrop-filter: blur(10px);
    padding: 16px 24px;
    border-radius: 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
}

.tool-card:hover {
    transform: translateY(-4px);
    background: var(--accent-primary);
    color: white;
}

.tool-card i {
    font-size: 1.5rem;
    display: block;
    margin-bottom: 8px;
}

.tool-content {
    background: var(--card-bg);
    backdrop-filter: blur(10px);
    border-radius: 24px;
    padding: 24px;
    min-height: 200px;
}

/* Modals */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.glass-modal {
    background: var(--card-bg);
    backdrop-filter: blur(20px);
    border-radius: 32px;
    width: 90%;
    max-width: 500px;
    border: 1px solid var(--glass-border);
}

.small-modal .glass-modal {
    max-width: 400px;
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-body {
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.modal-footer {
    padding: 20px 24px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
}

.setting-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.setting-group label {
    font-weight: 600;
    font-size: 0.875rem;
}

.setting-group select {
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    background: var(--bg-primary);
    color: var(--text-primary);
}

.theme-selector {
    display: flex;
    gap: 12px;
}

.theme-option {
    flex: 1;
    padding: 8px;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    background: var(--bg-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.theme-option.active {
    background: var(--accent-primary);
    color: white;
    border-color: transparent;
}

.close-modal, .close-calculator, .close-currency, .close-weather {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-secondary);
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    color: white;
    border: none;
    padding: 10px 24px;
    border-radius: 40px;
    cursor: pointer;
}

/* Calculator */
.calc-input {
    width: 100%;
    padding: 12px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    color: var(--text-primary);
    text-align: left;
    font-size: 1.2rem;
}

.calc-buttons {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

.calc-btn {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    padding: 12px;
    border-radius: 12px;
    cursor: pointer;
    color: var(--text-primary);
    font-size: 1.1rem;
}

.calc-btn.calc-op {
    background: var(--accent-primary);
    color: white;
}

.calc-btn.calc-equal {
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    color: white;
    grid-column: span 2;
}

.calc-btn.calc-clear {
    background: #ef4444;
    color: white;
    grid-column: span 2;
}

.calc-result {
    text-align: center;
    font-size: 1.2rem;
    font-weight: bold;
    color: var(--accent-primary);
    padding: 12px;
}

/* Currency Converter */
.currency-converter {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.currency-converter input, .currency-converter select {
    padding: 10px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    color: var(--text-primary);
}

.swap-currency {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    color: var(--accent-primary);
}

.currency-result {
    text-align: center;
    font-size: 1.2rem;
    font-weight: bold;
    padding: 12px;
    background: var(--bg-primary);
    border-radius: 12px;
}

/* Weather Result */
.weather-result {
    background: var(--bg-primary);
    border-radius: 12px;
    padding: 16px;
    text-align: center;
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: -280px;
        top: 0;
        bottom: 0;
        z-index: 20;
    }
    
    .sidebar.active {
        left: 0;
    }
    
    .menu-toggle {
        display: block;
    }
    
    .hero-glass {
        padding: 32px 20px;
    }
    
    .hero-title {
        font-size: 1.75rem;
    }
    
    .search-tabs {
        flex-wrap: wrap;
    }
    
    .tab-btn {
        padding: 6px 12px;
        font-size: 0.7rem;
    }
    
    .search-filters {
        flex-direction: column;
        align-items: stretch;
    }
    
    .filter-group {
        justify-content: space-between;
    }
    
    .results-container.grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .example-searches {
        flex-direction: column;
        align-items: stretch;
    }
    
    .example-btn {
        width: 100%;
        text-align: center;
    }
    
    .tools-grid {
        flex-wrap: wrap;
    }
    
    .tool-card {
        flex: 1;
        min-width: 80px;
        padding: 12px;
    }
}