@font-face {
    font-family: 'IRANSansX';
    src: url('fonts/IRANSansX-Regular.woff2') format('woff2');
    font-weight: normal;
    font-style: normal;
}
@font-face {
    font-family: 'IRANSansX';
    src: url('fonts/IRANSansX-Bold.woff2') format('woff2');
    font-weight: bold;
    font-style: normal;
}

:root[data-theme="light"] {
    --md-sys-color-primary: #ff6b00;
    --md-sys-color-on-primary: #ffffff;
    --md-sys-color-primary-container: #fff4ed;
    --md-sys-color-background: #fafafa;
    --md-sys-color-surface: #ffffff;
    --md-sys-color-surface-container: #f4f4f5;
    --md-sys-color-surface-container-high: #e4e4e7;
    --md-sys-color-on-surface: #18181b;
    --md-sys-color-on-surface-variant: #71717a;
    --md-sys-color-outline: #d4d4d8;
    --md-sys-color-error: #ef4444;
    --md-elevation-1: 0 4px 20px -2px rgba(0, 0, 0, 0.05);
    --md-elevation-3: 0 10px 30px -5px rgba(0, 0, 0, 0.08);
}

:root[data-theme="dark"] {
    --md-sys-color-primary: #ff8533;
    --md-sys-color-on-primary: #1a0b00;
    --md-sys-color-primary-container: #331500;
    --md-sys-color-background: #09090b;
    --md-sys-color-surface: #18181b;
    --md-sys-color-surface-container: #27272a;
    --md-sys-color-surface-container-high: #3f3f46;
    --md-sys-color-on-surface: #f4f4f5;
    --md-sys-color-on-surface-variant: #a1a1aa;
    --md-sys-color-outline: #3f3f46;
    --md-sys-color-error: #f87171;
    --md-elevation-1: 0 4px 20px -2px rgba(0, 0, 0, 0.4);
    --md-elevation-3: 0 10px 30px -5px rgba(0, 0, 0, 0.6);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

body {
    background-color: var(--md-sys-color-background);
    color: var(--md-sys-color-on-surface);
    font-family: 'IRANSansX', system-ui, sans-serif;
    display: flex; justify-content: center; align-items: center;
    height: 100vh; overflow: hidden;
    transition: background-color 0.4s ease, color 0.4s ease;
}

.primary-text { color: var(--md-sys-color-primary); }
.hidden { display: none !important; }

.master-container {
    width: 100%; max-width: 1440px; height: 100vh;
    display: grid; grid-template-columns: 420px 1fr;
    background-color: var(--md-sys-color-surface);
    box-shadow: var(--md-elevation-3);
    overflow: hidden;
    transition: background-color 0.4s ease, box-shadow 0.4s ease;
}
@media (max-width: 1440px) { .master-container { border-radius: 0; height: 100vh; } }

.md-sidebar {
    background-color: var(--md-sys-color-surface-container);
    display: flex; flex-direction: column; height: 100%;
    border-left: 1px solid var(--md-sys-color-outline);
    z-index: 10; overflow-y: auto;
    transition: background-color 0.4s ease, border-color 0.4s ease;
}

.md-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 1.5rem; background-color: var(--md-sys-color-surface-container);
    position: sticky; top: 0; z-index: 20;
    border-bottom: 1px solid var(--md-sys-color-outline);
    transition: background-color 0.4s ease, border-color 0.4s ease;
}

.brand h1 { font-size: 1.6rem; font-weight: 800; letter-spacing: -0.5px; }
.header-actions { display: flex; align-items: center; gap: 0.8rem; }

.md-chip {
    background-color: var(--md-sys-color-primary-container);
    color: var(--md-sys-color-on-surface);
    padding: 0.4rem 1rem; border-radius: 20px;
    font-size: 0.85rem; font-weight: bold;
    display: flex; align-items: center; gap: 0.4rem;
    transition: background-color 0.4s ease, color 0.4s ease;
}

.md-content { padding: 1.5rem; display: flex; flex-direction: column; gap: 1.5rem; }

.md-card {
    background-color: var(--md-sys-color-surface);
    border-radius: 24px; padding: 1.5rem;
    display: flex; flex-direction: column; gap: 1.5rem;
    transition: background-color 0.4s ease, box-shadow 0.4s ease;
}
.elevation-1 { box-shadow: var(--md-elevation-1); }

.md-input-group { display: flex; flex-direction: column; gap: 0.6rem; }
.md-input-group label { font-size: 0.85rem; color: var(--md-sys-color-on-surface-variant); font-weight: 600; }

.md-text-field {
    background-color: var(--md-sys-color-background);
    border: 1px solid var(--md-sys-color-outline);
    border-radius: 14px; padding: 1rem 1.2rem;
    color: var(--md-sys-color-on-surface);
    font-family: inherit; font-size: 0.95rem;
    transition: border-color 0.3s, box-shadow 0.3s, background-color 0.4s ease, color 0.4s ease;
}
.md-text-field:focus {
    outline: none; border-color: var(--md-sys-color-primary);
    background-color: var(--md-sys-color-surface);
    box-shadow: inset 0 0 0 1px var(--md-sys-color-primary);
}
textarea.md-text-field { height: 110px; resize: vertical; line-height: 1.5; }
select.md-text-field { cursor: pointer; appearance: none; }

.md-button {
    display: flex; justify-content: center; align-items: center; gap: 0.5rem;
    padding: 1rem 1.5rem; border-radius: 100px;
    font-family: inherit; font-size: 1rem; font-weight: bold;
    cursor: pointer; border: none; transition: all 0.3s ease;
}
.md-button-filled {
    background-color: var(--md-sys-color-primary);
    color: var(--md-sys-color-on-primary);
    box-shadow: 0 4px 12px rgba(255, 107, 0, 0.2);
}
.md-button-filled:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(255, 107, 0, 0.3); }
.md-button:disabled { opacity: 0.6; cursor: not-allowed; transform: none; box-shadow: none; }

.md-button-tonal {
    background-color: var(--md-sys-color-surface-container-high);
    color: var(--md-sys-color-on-surface);
}
.md-button-tonal:hover { background-color: var(--md-sys-color-outline); }

.md-icon-button {
    background: var(--md-sys-color-surface-container-high);
    color: var(--md-sys-color-on-surface);
    border: none; border-radius: 50%; width: 40px; height: 40px;
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    font-size: 1.2rem; transition: all 0.3s ease;
}
.md-icon-button:hover { background: var(--md-sys-color-outline); }

.tabs { display: flex; border-bottom: 2px solid var(--md-sys-color-surface-container-high); margin-bottom: 1.5rem; }
.tab-btn { flex: 1; padding: 1rem; cursor: pointer; background: none; border: none; font-size: 1rem; font-family: inherit; font-weight: bold; color: var(--md-sys-color-on-surface-variant); transition: all 0.2s; }
.tab-btn.active { border-bottom: 2px solid var(--md-sys-color-primary); color: var(--md-sys-color-primary); }

.idea-desc-box { background: var(--md-sys-color-surface-container); padding: 1rem; border-radius: 8px; margin-bottom: 1rem; font-size: 0.9rem; line-height: 1.6; border-right: 3px solid var(--md-sys-color-primary); }

.md-main-area {
    display: flex; flex-direction: column; height: 100vh;
    background-color: var(--md-sys-color-surface);
    transition: background-color 0.4s ease;
}
.gallery-toolbar { padding: 2.5rem 2.5rem 1rem 2.5rem; }
.md-headline { font-size: 2rem; font-weight: 800; margin-bottom: 0.5rem; letter-spacing: -0.5px; }
.md-body-medium { color: var(--md-sys-color-on-surface-variant); font-size: 1.1rem; }

.gallery-scroll-area { flex: 1; overflow-y: auto; padding: 1rem 2.5rem 2.5rem 2.5rem; }

.md-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 1.5rem; }

.md-gallery-card {
    border-radius: 20px; overflow: hidden; cursor: pointer;
    background-color: var(--md-sys-color-surface-container);
    aspect-ratio: 1 / 1; position: relative;
    border: 1px solid var(--md-sys-color-outline);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.3s ease;
}
.md-gallery-card:hover { transform: translateY(-6px) scale(1.02); box-shadow: var(--md-elevation-3); z-index: 2; }
.md-gallery-card img { width: 100%; height: 100%; object-fit: cover; pointer-events: none; }

.md-results-section { margin-top: 1rem; }
.section-title { font-size: 1.2rem; margin-bottom: 1rem; font-weight: 800; }
.md-results-grid { display: flex; flex-direction: column; gap: 1.5rem; }
.result-card {
    background-color: var(--md-sys-color-surface);
    border-radius: 24px; overflow: hidden;
    box-shadow: var(--md-elevation-1);
    border: 1px solid var(--md-sys-color-outline);
    transition: all 0.4s ease;
}
.result-card img { width: 100%; display: block; border-bottom: 1px solid var(--md-sys-color-outline); }
.result-actions { padding: 1.5rem; display: flex; flex-direction: column; gap: 1rem; background-color: var(--md-sys-color-background); }

.loading-container { text-align: center; padding: 4rem; color: var(--md-sys-color-on-surface-variant); }
.md-circular-progress {
    border: 3px solid var(--md-sys-color-surface-container-high);
    border-top: 3px solid var(--md-sys-color-primary);
    border-radius: 50%; width: 40px; height: 40px;
    animation: spin 0.8s linear infinite; margin: 0 auto 1rem auto;
}
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--md-sys-color-outline); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--md-sys-color-on-surface-variant); }
