/* ==============================================================================
   3omar.hs — Interactive Study Companion & Avatar Customization Widget
   Academic / 2D Vector Theme with Smooth Interactions & Full Modal Customizer
   ============================================================================== */

:root {
    --comp-primary: #10b981;
    --comp-accent: #38bdf8;
    --comp-pink: #f43f5e;
    --comp-gold: #f59e0b;
    --comp-bg-card: rgba(15, 23, 42, 0.85);
    --comp-border: rgba(255, 255, 255, 0.12);
    --comp-shadow: 0 20px 50px rgba(0, 0, 0, 0.4);
}

/* ── Widget Outer Container ── */
.companion-section {
    max-width: 900px;
    margin: 4rem auto 2rem;
    padding: 2.5rem 1.5rem;
    background: var(--comp-bg-card);
    border: 1px solid var(--comp-border);
    border-radius: 28px;
    backdrop-filter: blur(16px);
    box-shadow: var(--comp-shadow);
    position: relative;
    overflow: hidden;
    direction: rtl;
    text-align: center;
    font-family: 'Tajawal', 'Outfit', system-ui, sans-serif;
}

.companion-section::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle at center, rgba(56, 189, 248, 0.04) 0%, transparent 60%);
    pointer-events: none;
    z-index: 0;
}

/* ── Section Header ── */
.companion-header {
    position: relative;
    z-index: 1;
    margin-bottom: 1.75rem;
}

.companion-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 18px;
    border-radius: 9999px;
    background: rgba(16, 185, 129, 0.12);
    border: 1px solid rgba(16, 185, 129, 0.3);
    color: #34d399;
    font-size: 13px;
    font-weight: 700;
    margin-bottom: 10px;
}

.companion-title {
    font-size: 2.2rem;
    font-weight: 800;
    margin-bottom: 0.5rem;
    background: linear-gradient(135deg, #fff 30%, #38bdf8 70%, #10b981 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.5px;
}

.companion-subtitle {
    font-size: 15px;
    color: #94a3b8;
    max-width: 650px;
    margin: 0 auto 1.25rem;
    line-height: 1.6;
}

.companion-top-actions {
    display: flex;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.btn-open-modal {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 11px 26px;
    border-radius: 9999px;
    background: linear-gradient(135deg, #10b981, #059669);
    color: #fff;
    font-size: 15px;
    font-weight: 700;
    border: none;
    cursor: pointer;
    box-shadow: 0 8px 25px rgba(16, 185, 129, 0.35);
    transition: all 0.25s ease;
}

.btn-open-modal:hover {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 12px 30px rgba(16, 185, 129, 0.5);
}

.btn-quick-random {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 11px 22px;
    border-radius: 9999px;
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid var(--comp-border);
    color: #e2e8f0;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s ease;
}

.btn-quick-random:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    transform: translateY(-2px);
}

/* ── Character Stage & Paper Canvas ── */
.character-stage {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 680px;
    min-height: 520px;
    margin: 0 auto;
    border-radius: 24px;
    background-color: #f8fafc;
    /* Clean 2D Academic Grid Background */
    background-image: 
        linear-gradient(to right, rgba(56, 189, 248, 0.08) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(56, 189, 248, 0.08) 1px, transparent 1px);
    background-size: 24px 24px;
    border: 2px solid rgba(226, 232, 240, 0.9);
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.05), 0 16px 40px rgba(0, 0, 0, 0.35);
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    user-select: none;
    touch-action: manipulation;
}

/* Floating Toolbar (Side Pill) */
.char-toolbar {
    position: absolute;
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(226, 232, 240, 0.8);
    border-radius: 40px;
    padding: 12px 8px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    z-index: 10;
}

.tool-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 1px solid rgba(203, 213, 225, 0.8);
    background: #fff;
    color: #334155;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
    position: relative;
}

.tool-btn:hover {
    transform: scale(1.12);
    border-color: #38bdf8;
    box-shadow: 0 6px 16px rgba(56, 189, 248, 0.25);
}

.tool-btn.active {
    background: #0284c7;
    color: #fff;
    border-color: #0284c7;
    box-shadow: 0 0 15px rgba(2, 132, 199, 0.4);
}

.tool-btn[data-tool="sound"].muted {
    opacity: 0.6;
    background: #f1f5f9;
}

/* Tool Tooltip */
.tool-btn::after {
    content: attr(data-tooltip);
    position: absolute;
    right: 120%;
    top: 50%;
    transform: translateY(-50%);
    background: #0f172a;
    color: #fff;
    padding: 4px 10px;
    border-radius: 8px;
    font-size: 12px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    font-family: 'Tajawal', sans-serif;
    box-shadow: 0 4px 12px rgba(0,0,0,0.25);
    z-index: 20;
}

.tool-btn:hover::after {
    opacity: 1;
}

/* ── Interactive Companion SVG ── */
.companion-svg {
    width: 100%;
    max-width: 480px;
    height: 480px;
    filter: drop-shadow(0 12px 20px rgba(0, 0, 0, 0.08));
    cursor: pointer;
    transition: transform 0.1s ease;
}

/* SVG Interactive Parts Styling & Hover Effects */
.clickable-part {
    cursor: pointer;
    transition: transform 0.15s ease, filter 0.15s ease;
}

.clickable-part:hover {
    filter: brightness(1.06);
}

.interactive-ear {
    cursor: grab;
    transition: transform 0.15s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.interactive-ear:active {
    cursor: grabbing;
}

/* Doodles and Sticker Overlay Canvas */
.sticker-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 5;
}

.stamped-sticker {
    position: absolute;
    transform: translate(-50%, -50%);
    font-size: 32px;
    user-select: none;
    animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    pointer-events: auto;
    cursor: pointer;
    filter: drop-shadow(0 4px 8px rgba(0,0,0,0.15));
}

@keyframes popIn {
    0% { transform: translate(-50%, -50%) scale(0) rotate(-25deg); opacity: 0; }
    80% { transform: translate(-50%, -50%) scale(1.2) rotate(10deg); }
    100% { transform: translate(-50%, -50%) scale(1) rotate(0); opacity: 1; }
}

/* Foam Bubbles on Cleaning */
.cleaning-bubble {
    position: absolute;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, rgba(255,255,255,0.9), rgba(56,189,248,0.4));
    border: 1px solid rgba(255,255,255,0.8);
    pointer-events: none;
    animation: bubbleFloat 0.8s ease-out forwards;
}

@keyframes bubbleFloat {
    0% { transform: scale(0.3); opacity: 1; }
    100% { transform: scale(1.4) translateY(-25px); opacity: 0; }
}

/* ── Interactive Hints Pill Bar (Bottom) ── */
.companion-hints-bar {
    margin-top: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 24px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--comp-border);
    border-radius: 9999px;
    color: #cbd5e1;
    font-size: 13.5px;
    font-weight: 600;
    backdrop-filter: blur(8px);
    flex-wrap: wrap;
}

.hint-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    transition: color 0.2s;
}

.hint-item:hover {
    color: var(--comp-accent);
}

.hint-sep {
    color: rgba(255, 255, 255, 0.2);
    margin: 0 4px;
}

/* ── Customization Modal ("تخصيص رفيقك التوجيهي") ── */
.companion-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(11, 15, 25, 0.75);
    backdrop-filter: blur(12px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    direction: rtl;
}

.companion-modal-overlay.open {
    opacity: 1;
    visibility: visible;
}

.companion-modal-card {
    background: #ffffff;
    color: #1e293b;
    width: 100%;
    max-width: 460px;
    max-height: 90vh;
    border-radius: 28px;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.35);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: scale(0.92) translateY(20px);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    border: 1px solid rgba(226, 232, 240, 0.9);
}

.companion-modal-overlay.open .companion-modal-card {
    transform: scale(1) translateY(0);
}

/* Modal Header */
.modal-top-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid #f1f5f9;
}

.modal-title-text {
    font-size: 20px;
    font-weight: 800;
    color: #0f172a;
    display: flex;
    align-items: center;
    gap: 8px;
}

.modal-close-btn {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: #f1f5f9;
    border: none;
    color: #64748b;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.modal-close-btn:hover {
    background: #e2e8f0;
    color: #0f172a;
}

/* Modal Scrollable Body */
.modal-body-scroll {
    padding: 20px 24px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

/* Form Sections */
.modal-field-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    text-align: right;
}

.modal-field-label {
    font-size: 14px;
    font-weight: 700;
    color: #334155;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Gender Toggle Buttons */
.gender-toggle-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.gender-btn {
    padding: 12px 14px;
    border-radius: 16px;
    border: 2px solid #e2e8f0;
    background: #f8fafc;
    color: #475569;
    font-size: 15px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.gender-btn:hover {
    border-color: #cbd5e1;
    background: #f1f5f9;
}

.gender-btn.active {
    background: #fff1f2;
    border-color: #f43f5e;
    color: #e11d48;
    box-shadow: 0 4px 14px rgba(244, 63, 94, 0.15);
}

.gender-btn[data-gender="male"].active {
    background: #f0fdf4;
    border-color: #10b981;
    color: #059669;
    box-shadow: 0 4px 14px rgba(16, 185, 129, 0.15);
}

/* Eye Color Picker Pills */
.eye-colors-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}

.eye-color-pill {
    padding: 10px 8px;
    border-radius: 14px;
    border: 2px solid #e2e8f0;
    background: #fff;
    color: #334155;
    font-size: 13.5px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.color-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}

.eye-color-pill.active {
    border-color: #f59e0b;
    background: #fffbeb;
    color: #b45309;
    box-shadow: 0 2px 8px rgba(245, 158, 11, 0.2);
}

/* Inputs & Dropdowns */
.modal-input {
    width: 100%;
    padding: 12px 16px;
    border-radius: 14px;
    border: 1.5px solid #e2e8f0;
    background: #f8fafc;
    color: #0f172a;
    font-size: 15px;
    font-weight: 600;
    outline: none;
    transition: all 0.2s;
    box-sizing: border-box;
    font-family: inherit;
    text-align: right;
}

.modal-input:focus {
    border-color: #0284c7;
    background: #fff;
    box-shadow: 0 0 0 4px rgba(2, 132, 199, 0.12);
}

/* Upcoming Features Callout Card */
.modal-coming-soon-card {
    background: #f0fdfa;
    border: 1.5px dashed #2dd4bf;
    border-radius: 18px;
    padding: 14px 18px;
    text-align: right;
}

.coming-soon-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
}

.coming-soon-title {
    font-size: 14px;
    font-weight: 800;
    color: #0f766e;
    display: flex;
    align-items: center;
    gap: 6px;
}

.coming-soon-badge {
    background: #ccfbf1;
    color: #0f766e;
    font-size: 11px;
    font-weight: 800;
    padding: 3px 10px;
    border-radius: 9999px;
    border: 1px solid #99f6e4;
}

.coming-soon-desc {
    font-size: 12.5px;
    color: #115e59;
    line-height: 1.5;
    margin: 0;
}

/* Reset to Default Button */
.btn-reset-default {
    width: 100%;
    padding: 12px;
    border-radius: 14px;
    background: #fff1f2;
    border: 1.5px solid #fecdd3;
    color: #e11d48;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s;
    font-family: inherit;
}

.btn-reset-default:hover {
    background: #ffe4e6;
    border-color: #fda4af;
}

/* Modal Bottom Action Row */
.modal-footer-row {
    padding: 16px 24px 22px;
    border-top: 1px solid #f1f5f9;
    display: flex;
    gap: 12px;
    align-items: center;
}

.btn-modal-cancel {
    padding: 12px 24px;
    border-radius: 14px;
    background: #f1f5f9;
    border: none;
    color: #64748b;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.btn-modal-cancel:hover {
    background: #e2e8f0;
    color: #334155;
}

.btn-modal-save {
    flex: 1;
    padding: 13px 24px;
    border-radius: 14px;
    background: #059669;
    border: none;
    color: #fff;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: 0 4px 15px rgba(5, 150, 105, 0.35);
    transition: all 0.2s;
    font-family: inherit;
}

.btn-modal-save:hover {
    background: #047857;
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(5, 150, 105, 0.45);
}

/* ── Responsiveness ── */
@media (max-width: 640px) {
    .companion-title {
        font-size: 1.75rem;
    }
    .character-stage {
        min-height: 440px;
    }
    .char-toolbar {
        left: 10px;
        padding: 8px 6px;
        gap: 8px;
    }
    .tool-btn {
        width: 38px;
        height: 38px;
        font-size: 17px;
    }
    .eye-colors-row {
        grid-template-columns: repeat(2, 1fr);
    }
}
