:root {
    --bg-dark: #0a0a0a;
    --surface: #141414;
    --surface-hover: #1f1f1f;
    --border-color: #333333;
    
    --text-primary: #ffffff;
    --text-secondary: #a3a3a3;
    
    --gold-primary: #d4af37;
    --gold-light: #f3e5ab;
    --gold-dark: #b8960b;
    --gold-gradient: linear-gradient(135deg, #d4af37 0%, #ffdf70 50%, #b8960b 100%);
    
    --shadow-soft: 0 8px 30px rgba(0, 0, 0, 0.5);
    --shadow-gold: 0 4px 15px rgba(212, 175, 55, 0.15);
    
    --font-en: 'Outfit', sans-serif;
    --font-ar: 'Cairo', sans-serif;
}

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

body {
    background-color: var(--bg-dark);
    color: var(--text-primary);
    font-family: var(--font-en);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow-x: hidden;
}

/* Layout */
.container {
    width: 100%;
    max-width: 480px;
    padding: 2rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
    z-index: 1;
}

/* Header */
header {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.brand {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.logo-icon {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 14px;
    font-size: 1.5rem;
    color: var(--bg-dark);
    background: var(--gold-gradient);
    box-shadow: var(--shadow-gold);
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: row-reverse;
    gap: 0.5rem;
    font-family: var(--font-ar);
    font-weight: 800;
    font-size: 2.2rem;
    letter-spacing: -0.5px;
    background: var(--gold-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;
}

.logo span {
    font-family: var(--font-en);
    font-weight: 700;
    font-size: 1.8rem;
    opacity: 0.8;
    margin-left: 0.2rem;
    color: var(--gold-light);
    -webkit-text-fill-color: initial;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 0.95rem;
    font-weight: 400;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    margin-top: 0.25rem;
}

/* Cards */
.converter-card {
    background-color: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    box-shadow: var(--shadow-soft);
    position: relative;
}

.converter-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 2px;
    background: var(--gold-gradient);
    border-top-left-radius: 20px;
    border-top-right-radius: 20px;
}

/* Input Sections */
.input-section {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.section-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 500;
    padding-left: 0.25rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.glass-input {
    display: flex;
    align-items: center;
    background: #000000;
    border-radius: 12px;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    transition: all 0.3s ease;
}

.glass-input:focus-within {
    border-color: var(--gold-primary);
    box-shadow: 0 0 0 2px rgba(212, 175, 55, 0.2);
}

.focus-highlight {
    background: #080808;
}

.currency-selector {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding-right: 1rem;
    border-right: 1px solid var(--border-color);
    position: relative;
    cursor: pointer;
}

.flag-icon {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid var(--border-color);
}

.currency-select {
    appearance: none;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-family: var(--font-en);
    font-weight: 600;
    font-size: 1.1rem;
    cursor: pointer;
    outline: none;
    padding-right: 1.5rem;
}

.currency-select option {
    background: var(--surface);
    color: var(--text-primary);
}

.select-arrow {
    position: absolute;
    right: 0.2rem;
    color: var(--gold-primary);
    pointer-events: none;
    font-size: 0.9rem;
}

.amount-input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--gold-light);
    font-family: var(--font-en);
    font-weight: 600;
    font-size: 1.5rem;
    text-align: right;
    outline: none;
    width: 100%;
}

.amount-input::placeholder {
    color: #444444;
}

.currency-name {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-align: right;
    padding-right: 0.25rem;
}

/* Swap Button & Divider */
.swap-container {
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    margin: 0.5rem 0;
}

.swap-container .line {
    flex: 1;
    height: 1px;
    background: var(--border-color);
}

.swap-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 1px solid var(--gold-primary);
    background: #000000;
    color: var(--gold-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 2;
}

.swap-btn:hover {
    background: var(--gold-primary);
    color: #000;
    transform: rotate(180deg) scale(1.1);
    box-shadow: var(--shadow-gold);
}

.swap-btn:active {
    transform: rotate(180deg) scale(0.95);
}

/* Details section */
.glass-details {
    background: #000000;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.25rem;
    margin-top: 0.5rem;
}

.detail-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
    font-size: 0.85rem;
}

.detail-row.last {
    margin-bottom: 0;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border-color);
}

.detail-label {
    color: var(--text-secondary);
}

.detail-value {
    color: var(--text-primary);
    font-weight: 500;
}

.detail-value.highlight {
    color: var(--gold-primary);
    font-weight: 600;
}

.detail-value.green {
    color: var(--gold-light);
}

/* Primary Button */
.primary-btn {
    width: 100%;
    padding: 1rem;
    border-radius: 12px;
    border: none;
    background: var(--gold-gradient);
    color: var(--bg-dark);
    font-family: var(--font-en);
    font-weight: 700;
    font-size: 1.1rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: all 0.3s ease;
    box-shadow: var(--shadow-gold);
    margin-top: 0.5rem;
}

.primary-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(212, 175, 55, 0.3);
    filter: brightness(1.1);
}

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

/* Footer */
footer {
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.8rem;
    opacity: 0.6;
}

/* Developer Credit Block */
.dev-credit {
    margin-top: 1rem;
    border-radius: 14px;
    padding: 1rem 1.25rem 0.85rem;
    position: relative;
    background: rgba(212, 175, 55, 0.04);
}

.dev-line {
    position: absolute;
    top: 0;
    left: 12px;
    right: 12px;
    height: 3px;
    background: var(--gold-gradient);
    border-radius: 0 0 4px 4px;
}

.dev-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--text-secondary);
    font-weight: 600;
    margin-bottom: 0.6rem;
    margin-top: 0.25rem;
}

.dev-names {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.4rem 1.5rem;
}

.dev-names span {
    font-size: 0.82rem;
    color: var(--gold-light);
    font-weight: 500;
    font-family: var(--font-en);
    letter-spacing: 0.3px;
}

.dev-names span:nth-child(odd) {
    text-align: left;
}

.dev-names span:nth-child(even) {
    text-align: right;
}

.school-info {
    margin-top: 0.75rem;
    padding-top: 0.6rem;
    border-top: 1px solid rgba(212, 175, 55, 0.1);
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 500;
    letter-spacing: 0.5px;
    opacity: 0.9;
}

/* Animations */
.fade-in-up {
    animation: fadeInUp 0.8s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    opacity: 0;
    transform: translateY(20px);
}

.delay-1 { animation-delay: 0.1s; }
.delay-2 { animation-delay: 0.2s; }

@keyframes fadeInUp {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Currency Selector Trigger */
.currency-selector {
    cursor: pointer;
    transition: opacity 0.2s;
}
.currency-selector:hover {
    opacity: 0.8;
}
.currency-selector:hover .select-arrow {
    color: var(--gold-light);
}

/* Picker Overlay */
.picker-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    z-index: 100;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}
.picker-overlay.active {
    opacity: 1;
    pointer-events: all;
}

/* Picker Panel */
.currency-picker {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%) translateY(100%);
    width: 100%;
    max-width: 480px;
    max-height: 85vh;
    background: #141414;
    border: 1px solid #2a2a2a;
    border-bottom: none;
    border-radius: 24px 24px 0 0;
    z-index: 101;
    display: flex;
    flex-direction: column;
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 -8px 40px rgba(0,0,0,0.6);
}
.currency-picker.active {
    transform: translateX(-50%) translateY(0);
}

/* Picker Handle bar */
.currency-picker::before {
    content: '';
    display: block;
    width: 40px;
    height: 4px;
    background: #333;
    border-radius: 2px;
    margin: 12px auto 0;
    flex-shrink: 0;
}

/* Picker Header */
.picker-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem 0.75rem;
    flex-shrink: 0;
}
.picker-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
    font-family: var(--font-en);
}
.picker-close {
    background: #222;
    border: 1px solid #333;
    color: var(--text-secondary);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.1rem;
    transition: all 0.2s;
}
.picker-close:hover {
    background: #333;
    color: var(--text-primary);
}

/* Search Bar */
.picker-search-wrap {
    position: relative;
    padding: 0 1.25rem 0.75rem;
    flex-shrink: 0;
}
.search-icon {
    position: absolute;
    left: 2rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    font-size: 1rem;
    pointer-events: none;
}
[dir="rtl"] .search-icon {
    left: auto;
    right: 2rem;
}
.picker-search {
    width: 100%;
    background: #000;
    border: 1px solid #333;
    border-radius: 12px;
    color: var(--text-primary);
    font-family: var(--font-en);
    font-size: 0.95rem;
    padding: 0.7rem 1rem 0.7rem 2.5rem;
    outline: none;
    transition: border-color 0.2s;
}
[dir="rtl"] .picker-search {
    padding: 0.7rem 2.5rem 0.7rem 1rem;
}
.picker-search:focus {
    border-color: var(--gold-primary);
    box-shadow: 0 0 0 2px rgba(212, 175, 55, 0.15);
}
.picker-search::placeholder {
    color: #555;
}

/* Scrollable list */
.picker-list {
    overflow-y: auto;
    flex: 1;
    padding: 0 0.5rem 1.5rem;
}
.picker-list::-webkit-scrollbar {
    width: 4px;
}
.picker-list::-webkit-scrollbar-track {
    background: transparent;
}
.picker-list::-webkit-scrollbar-thumb {
    background: #333;
    border-radius: 2px;
}

/* Section heading inside list */
.picker-section-label {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--gold-primary);
    padding: 0.75rem 0.75rem 0.35rem;
}

/* Popular chips row */
.popular-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.25rem 0.75rem 0.75rem;
}
.popular-chip {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    background: #1a1a1a;
    border: 1px solid #2a2a2a;
    border-radius: 20px;
    padding: 0.3rem 0.7rem;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-primary);
}
.popular-chip img {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    object-fit: cover;
}
.popular-chip:hover, .popular-chip.selected {
    background: rgba(212, 175, 55, 0.12);
    border-color: var(--gold-primary);
    color: var(--gold-light);
}

/* Divider inside list */
.picker-divider {
    height: 1px;
    background: #222;
    margin: 0.25rem 0.75rem 0.5rem;
}

/* Currency list rows */
.picker-item {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.7rem 0.75rem;
    border-radius: 12px;
    cursor: pointer;
    transition: background 0.15s ease;
}
.picker-item:hover {
    background: #1f1f1f;
}
.picker-item.selected {
    background: rgba(212, 175, 55, 0.08);
}
.picker-item img {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid #333;
    flex-shrink: 0;
}
.picker-item-info {
    flex: 1;
    min-width: 0;
}
.picker-item-code {
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--text-primary);
    font-family: var(--font-en);
}
.picker-item-name {
    font-size: 0.78rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 1px;
}
.picker-item-check {
    color: var(--gold-primary);
    font-size: 1.1rem;
    flex-shrink: 0;
    opacity: 0;
    transition: opacity 0.15s;
}
.picker-item.selected .picker-item-check {
    opacity: 1;
}

.picker-no-results {
    text-align: center;
    color: var(--text-secondary);
    padding: 2rem 1rem;
    font-size: 0.9rem;
}

/* Responsive */

/* Body: allow scroll on smaller devices where content is taller than viewport */
@media (max-height: 700px) {
    body {
        align-items: flex-start;
    }
}

/* Tablets & small desktops */
@media (min-width: 600px) {
    .container {
        padding: 3rem 1.5rem;
    }
    .converter-card {
        padding: 2.5rem;
    }
    .currency-picker {
        max-height: 70vh;
        border-radius: 24px;
        bottom: auto;
        top: 50%;
        transform: translateX(-50%) translateY(-50%) scale(0.95);
        opacity: 0;
        border-bottom: 1px solid #2a2a2a;
        transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.35s ease;
    }
    .currency-picker.active {
        transform: translateX(-50%) translateY(-50%) scale(1);
        opacity: 1;
    }
}

/* Small phones */
@media (max-width: 400px) {
    .container {
        padding: 1.5rem 0.75rem;
        gap: 1.5rem;
    }
    .converter-card {
        padding: 1.25rem;
        border-radius: 16px;
        gap: 1rem;
    }
    .converter-card::before {
        border-top-left-radius: 16px;
        border-top-right-radius: 16px;
    }
    .amount-input {
        font-size: 1.25rem;
    }
    .logo {
        font-size: 1.8rem;
    }
    .logo span {
        font-size: 1.4rem;
    }
    .logo-icon {
        width: 40px;
        height: 40px;
        font-size: 1.2rem;
        border-radius: 12px;
    }
    .subtitle {
        font-size: 0.8rem;
    }
    .section-label {
        font-size: 0.75rem;
    }
    .glass-input {
        padding: 0.6rem 0.75rem;
    }
    .glass-details {
        padding: 1rem;
    }
    .detail-row {
        font-size: 0.8rem;
    }
    .swap-btn {
        width: 38px;
        height: 38px;
        font-size: 1rem;
    }
    .dev-names {
        gap: 0.3rem 1rem;
    }
    .dev-names span {
        font-size: 0.75rem;
    }
    .school-info {
        font-size: 0.68rem;
    }
    .popular-chips {
        gap: 0.4rem;
    }
    .popular-chip {
        font-size: 0.75rem;
        padding: 0.25rem 0.55rem;
    }
    .picker-item {
        padding: 0.6rem 0.6rem;
        gap: 0.65rem;
    }
    .picker-item img {
        width: 28px;
        height: 28px;
    }
}

/* Very small phones (iPhone SE, Galaxy Fold) */
@media (max-width: 340px) {
    .container {
        padding: 1rem 0.5rem;
        gap: 1.25rem;
    }
    .converter-card {
        padding: 1rem;
    }
    .logo {
        font-size: 1.5rem;
    }
    .logo span {
        font-size: 1.15rem;
    }
    .amount-input {
        font-size: 1.1rem;
    }
    .currency-select {
        font-size: 0.95rem;
    }
    .flag-icon {
        width: 20px;
        height: 20px;
    }
    .brand {
        gap: 0.6rem;
    }
    .dev-names {
        grid-template-columns: 1fr;
        gap: 0.25rem;
    }
    .dev-names span,
    .dev-names span:nth-child(odd),
    .dev-names span:nth-child(even) {
        text-align: center;
    }
}

/* Lang switcher responsive fix */
.lang-switcher {
    position: absolute;
    top: 1rem;
    right: 1rem;
    z-index: 10;
}
[dir="rtl"] .lang-switcher {
    right: auto;
    left: 1rem;
}

/* ========== RTL / Arabic Overrides ========== */
[dir="rtl"] body {
    font-family: var(--font-ar);
}

[dir="rtl"] .section-label {
    padding-left: 0;
    padding-right: 0.25rem;
}

[dir="rtl"] .currency-selector {
    padding-right: 0;
    padding-left: 1rem;
    border-right: none;
    border-left: 1px solid var(--border-color);
}

[dir="rtl"] .select-arrow {
    right: auto;
    left: 0.2rem;
}

[dir="rtl"] .currency-select {
    padding-right: 0;
    padding-left: 1.5rem;
}

[dir="rtl"] .amount-input {
    text-align: left;
}

[dir="rtl"] .currency-name {
    text-align: left;
    padding-right: 0;
    padding-left: 0.25rem;
}

[dir="rtl"] .glass-input {
    flex-direction: row-reverse;
}

[dir="rtl"] .detail-row {
    flex-direction: row-reverse;
}

[dir="rtl"] .picker-title {
    font-family: var(--font-ar);
}

[dir="rtl"] .picker-item-name {
    font-family: var(--font-ar);
}

[dir="rtl"] .picker-section-label {
    font-family: var(--font-ar);
    text-align: right;
}

[dir="rtl"] .picker-no-results {
    font-family: var(--font-ar);
}

[dir="rtl"] .dev-names span:nth-child(odd) {
    text-align: right;
}

[dir="rtl"] .dev-names span:nth-child(even) {
    text-align: left;
}

[dir="rtl"] .subtitle {
    font-family: var(--font-ar);
}

[dir="rtl"] .logo {
    flex-direction: row;
}
