:root {
    --bg-color: #0f172a;
    --card-bg: rgba(30, 41, 59, 0.65);
    --text-primary: #ffffff;
    --text-secondary: #cbd5e1;
    --primary-color: #4f46e5;
    --primary-hover: #4338ca;
    --success-color: #10b981;
    --success-hover: #059669;
    --danger-color: #e11d48;
    --danger-hover: #be123c;
    --border-color: rgba(255, 255, 255, 0.1);
    --shadow-md: 0 4px 30px rgba(0, 0, 0, 0.2);
    --glow-primary: 0 0 20px rgba(79, 70, 229, 0.5);
    --border-radius: 16px;
    --transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: 'Cairo', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 2rem 1rem;
    overflow-x: hidden;
    position: relative;
}

/* Background Animated Blobs */
.bg-blob {
    position: fixed;
    border-radius: 50%;
    filter: blur(80px);
    z-index: -1;
    opacity: 0.6;
    animation: drift 20s infinite alternate;
}

.blob-1 {
    width: 400px;
    height: 400px;
    background: #4f46e5; /* Indigo */
    top: -100px;
    left: -100px;
}

.blob-2 {
    width: 300px;
    height: 300px;
    background: #ec4899; /* Pink */
    bottom: 10%;
    right: -50px;
    animation-delay: -5s;
}

.blob-3 {
    width: 350px;
    height: 350px;
    background: #0ea5e9; /* Sky */
    top: 40%;
    left: 20%;
    animation-delay: -10s;
}

@keyframes drift {
    0% { transform: translateY(0) scale(1); }
    100% { transform: translateY(50px) scale(1.1); }
}

header {
    text-align: center;
    margin-bottom: 2rem;
    animation: fadeInDown 0.8s ease backwards;
    z-index: 10;
}

.glow-text, header h1 {
    font-size: 2.2rem;
    background: linear-gradient(135deg, #a855f7, #ec4899, #f43f5e);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 0.5rem;
    text-shadow: 0 0 25px rgba(236, 72, 153, 0.3);
}

header p {
    color: var(--text-secondary);
    font-size: 1.1rem;
    text-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

/* Progress Bar */
.progress-wrapper {
    width: 100%;
    max-width: 800px;
    margin-bottom: 1.5rem;
    z-index: 10;
}
.progress-wrapper.hidden { display: none; }
.progress-wrapper.active { display: block; animation: fadeIn 0.5s ease backwards;}

.progress-bar-container {
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #3b82f6, #ec4899);
    width: 25%;
    transition: width 0.5s ease;
    border-radius: 10px;
}

.progress-text {
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-align: right;
    margin-top: 0.5rem;
}

main {
    width: 100%;
    max-width: 800px;
    position: relative;
    z-index: 10;
    perspective: 1000px;
}

/* Glassmorphism Cards */
.step-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 2.5rem 2rem;
    box-shadow: var(--shadow-md);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    display: none;
    flex-direction: column;
    gap: 1.5rem;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.5s ease, transform 0.5s ease;
}

.step-card.active {
    display: flex;
    opacity: 1;
    transform: translateY(0);
}

.step-card.hidden {
    display: none;
}

h2 {
    font-size: 1.5rem;
    color: var(--text-primary);
    border-bottom: 1px solid rgba(255,255,255,0.05);
    padding-bottom: 0.8rem;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-top: -1rem;
}

.options-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.btn {
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.1);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 1rem;
    padding: 0.9rem 1.2rem;
    border-radius: 10px;
    cursor: pointer;
    transition: var(--transition);
    outline: none;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    font-weight: 600;
    backdrop-filter: blur(5px);
}

.btn:hover {
    background: rgba(255,255,255,0.1);
    transform: translateY(-3px);
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

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

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color), #6366f1);
    border: none;
}
.btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-hover), #4f46e5);
    box-shadow: var(--glow-primary);
}

.btn-success {
    background: linear-gradient(135deg, var(--success-color), #059669);
    border: none;
}
.btn-success:hover {
    box-shadow: 0 0 20px rgba(16, 185, 129, 0.4);
}

.btn-danger {
    background: linear-gradient(135deg, var(--danger-color), #be123c);
    border: none;
}

.w-100 { width: 100%; }
.mt-4 { margin-top: 1.5rem; }
.text-center { text-align: center; }

.custom-input-group {
    display: flex;
    gap: 0.5rem;
}

input[type="text"] {
    flex: 1;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255,255,255,0.1);
    color: var(--text-primary);
    padding: 0.9rem;
    border-radius: 10px;
    font-family: inherit;
    font-size: 1.05rem;
    transition: var(--transition);
}

input[type="text"]:focus {
    outline: none;
    border-color: #818cf8;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.3);
    background: rgba(0, 0, 0, 0.5);
}

.quick-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 1rem;
}

.quick-buttons .btn {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    border-radius: 8px;
    border: 1px solid rgba(255,255,255,0.05);
}

.history-list-preview, .tags-container {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    background: rgba(0, 0, 0, 0.15);
    padding: 1.2rem;
    border-radius: 12px;
    min-height: 70px;
    border: 1px dashed rgba(255,255,255,0.2);
}

.tag {
    background: linear-gradient(135deg, rgba(255,255,255,0.1), rgba(255,255,255,0.02));
    border: 1px solid rgba(255,255,255,0.1);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    animation: zoomIn 0.3s ease;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.tag span.remove {
    cursor: pointer;
    font-weight: bold;
    color: rgba(255,255,255,0.5);
    transition: color 0.2s;
}
.tag span.remove:hover {
    color: #ef4444;
}

/* Dashboard Styles */
.dashboard-header h2 {
    border-bottom: none;
    padding-bottom: 0;
    margin-bottom: 0;
}

.prediction-results {
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
}

.prediction-card {
    background: rgba(0,0,0,0.2);
    border: 1px solid rgba(255,255,255,0.05);
    border-radius: 12px;
    padding: 1.2rem;
    position: relative;
    overflow: hidden;
    transition: var(--transition);
}

.prediction-card:hover {
    transform: translateX(-5px);
    background: rgba(0,0,0,0.3);
}

.prediction-card.best {
    border-color: rgba(16, 185, 129, 0.4);
    background: linear-gradient(to right, rgba(16, 185, 129, 0.05), rgba(0,0,0,0.2));
}

.prediction-card.best::before {
    content: '🏆 الأول والأنسب';
    position: absolute;
    left: -35px;
    top: 20px;
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
    font-size: 0.75rem;
    padding: 0.3rem 3rem;
    transform: rotate(-45deg);
    font-weight: bold;
    z-index: 2;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

.pred-content {
    position: relative;
    z-index: 1;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.pred-name {
    font-size: 1.3rem;
    font-weight: bold;
    text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

.pred-percent {
    font-size: 1.8rem;
    font-weight: 700;
    color: #a855f7;
    text-shadow: 0 0 10px rgba(168, 85, 247, 0.3);
    font-variant-numeric: tabular-nums;
}
.prediction-card.best .pred-percent {
    color: #10b981;
    text-shadow: 0 0 10px rgba(16, 185, 129, 0.3);
}

.pred-bar-bg {
    width: 100%;
    height: 8px;
    background: rgba(255,255,255,0.05);
    border-radius: 4px;
    margin-top: 1rem;
    overflow: hidden;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.3);
}

.pred-bar {
    height: 100%;
    background: linear-gradient(90deg, #6366f1, #a855f7);
    border-radius: 4px;
    width: 0%;
    transition: width 1.5s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.prediction-card.best .pred-bar {
    background: linear-gradient(90deg, #10b981, #34d399);
}

.history-tape {
    display: flex;
    gap: 0.6rem;
    overflow-x: auto;
    padding: 1rem 0;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.2) transparent;
}

.history-tape::-webkit-scrollbar {
    height: 6px;
}
.history-tape::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.2);
    border-radius: 3px;
}

.history-item {
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.1);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-size: 0.95rem;
    white-space: nowrap;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* Animations */
@keyframes fadeInDown {
    from { opacity: 0; transform: translateY(-30px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes zoomIn {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@media (max-width: 768px) {
    .options-grid {
        grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    }
    .custom-input-group {
        flex-direction: column;
    }
    .btn {
        padding: 0.8rem 1rem;
    }
}

@media (max-width: 480px) {
    body {
        padding: 1rem 0.5rem;
    }
    header {
        margin-bottom: 1.5rem;
    }
    .glow-text, header h1 {
        font-size: 1.6rem;
    }
    header p {
        font-size: 0.95rem;
    }
    h2 {
        font-size: 1.25rem;
    }
    .step-card {
        padding: 1.25rem 1rem;
        gap: 1.2rem;
    }
    .options-grid {
        grid-template-columns: 1fr 1fr;
        gap: 0.5rem;
    }
    .quick-buttons .btn {
        padding: 0.4rem 0.8rem;
        font-size: 0.85rem;
        flex: 1 1 calc(50% - 0.5rem);
    }
    .pred-name {
        font-size: 1.1rem;
    }
    .pred-percent {
        font-size: 1.4rem;
    }
}

/* وسوم تحليل التوقع */
.pred-reasons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid rgba(255,255,255,0.05);
}

.pred-tag {
    font-size: 0.7rem;
    padding: 2px 8px;
    border-radius: 10px;
    background: rgba(99, 102, 241, 0.2);
    color: #a5b4fc;
    border: 1px solid rgba(99, 102, 241, 0.3);
}

.pred-tag.tag-new {
    background: rgba(16, 185, 129, 0.2);
    color: #6ee7b7;
    border-color: rgba(16, 185, 129, 0.3);
}

.pred-tag.tag-gap {
    background: rgba(245, 158, 11, 0.15);
    color: #fbbf24;
    border-color: rgba(245, 158, 11, 0.25);
}

/* ═══ نظام اختيار الأيقونات ═══ */

.icon-picker-toggle {
    margin-bottom: 0.5rem;
}

.icon-grid-wrapper {
    margin-top: 0.75rem;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    padding: 0.75rem;
    max-height: 350px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.2) transparent;
    transition: all 0.3s ease;
}

.icon-grid-wrapper::-webkit-scrollbar {
    width: 6px;
}
.icon-grid-wrapper::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.2);
    border-radius: 3px;
}

.icon-search {
    width: 100%;
    padding: 0.6rem 1rem;
    margin-bottom: 0.75rem;
    border-radius: 10px;
    border: 1px solid rgba(255,255,255,0.15);
    background: rgba(255,255,255,0.06);
    color: var(--text-primary);
    font-family: 'Cairo', sans-serif;
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.3s;
}
.icon-search:focus {
    border-color: var(--primary-color);
}

.icon-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(85px, 1fr));
    gap: 0.5rem;
}

.icon-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.2rem;
    padding: 0.5rem 0.25rem;
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 10px;
    background: rgba(255,255,255,0.04);
    cursor: pointer;
    transition: all 0.2s ease;
    color: var(--text-primary);
    font-family: 'Cairo', sans-serif;
}

.icon-btn:hover {
    background: rgba(99, 102, 241, 0.15);
    border-color: rgba(99, 102, 241, 0.4);
    transform: scale(1.05);
}

.icon-btn:active {
    transform: scale(0.95);
}

.icon-btn-pressed {
    background: var(--success-color) !important;
    border-color: var(--success-hover) !important;
    transform: scale(0.9) !important;
}

.icon-emoji {
    font-size: 2rem;
    line-height: 1.2;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* تنسيق صور Twemoji */
.icon-emoji img.emoji {
    height: 1em;
    width: 1em;
    margin: 0 .05em 0 .1em;
    vertical-align: -0.1em;
}

.icon-label {
    font-size: 0.65rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 80px;
    text-align: center;
}

@media (max-width: 480px) {
    .icon-grid {
        grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
    }
    .icon-emoji {
        font-size: 1.7rem;
    }
}
