/* Reset and General Settings */
:root {
    --bg-dark: #0b0b0d;
    --card-bg: rgba(22, 22, 26, 0.65);
    --card-border: rgba(212, 175, 55, 0.15);
    --gold-primary: #d4af37;
    --gold-light: #f3d06b;
    --gold-dark: #9f7c53;
    --gold-bronze: #c5a059;
    --gold-glow: rgba(212, 175, 55, 0.35);
    --text-light: #f5f5f7;
    --text-muted: #a0a0aa;
    --font-ui: 'Cairo', 'Tajawal', sans-serif;
    --border-radius: 16px;
    --transition-speed: 0.3s;
}

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

body {
    background-color: var(--bg-dark);
    color: var(--text-light);
    font-family: var(--font-ui);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    position: relative;
    background-image: 
        radial-gradient(circle at 10% 20%, rgba(212, 175, 55, 0.05) 0%, transparent 40%),
        radial-gradient(circle at 90% 80%, rgba(159, 124, 83, 0.06) 0%, transparent 40%);
}

/* Star Background Effect */
.stars-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    opacity: 0.6;
    background-image: 
        radial-gradient(white, rgba(255,255,255,.2) 2px, transparent 40px),
        radial-gradient(white, rgba(255,255,255,.15) 1px, transparent 30px);
    background-size: 550px 550px, 350px 350px;
    background-position: 0 0, 40px 60px;
    animation: twinkle 12s linear infinite;
}

@keyframes twinkle {
    0% { opacity: 0.5; }
    50% { opacity: 0.8; }
    100% { opacity: 0.5; }
}

/* Header Styling */
.app-header {
    text-align: center;
    padding: 2.5rem 1rem 1.5rem;
    z-index: 10;
    position: relative;
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 0.5rem;
}

.logo i {
    font-size: 2.2rem;
    color: var(--gold-primary);
}

.gold-glow {
    filter: drop-shadow(0 0 8px var(--gold-glow));
}

.app-header h1 {
    font-size: 2rem;
    font-weight: 800;
    background: linear-gradient(135deg, #ffffff 30%, var(--gold-light) 70%, var(--gold-bronze) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 2px 10px rgba(0,0,0,0.3);
}

.subtitle {
    font-size: 1rem;
    color: var(--text-muted);
    max-width: 600px;
    margin: 0 auto;
    font-weight: 300;
    line-height: 1.6;
}

/* Main Layout Grid */
.main-container {
    display: grid;
    grid-template-columns: 1.1fr 0.9fr;
    gap: 2rem;
    max-width: 1280px;
    width: 95%;
    margin: 0 auto 3rem;
    z-index: 10;
    position: relative;
}

/* Glassmorphism Cards */
.glass-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--border-radius);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
    padding: 2rem;
    transition: box-shadow var(--transition-speed), border var(--transition-speed);
}

.glass-card:hover {
    border-color: rgba(212, 175, 55, 0.25);
    box-shadow: 0 12px 35px rgba(212, 175, 55, 0.05);
}

/* Section Title */
.section-title {
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    padding-bottom: 0.8rem;
}

.gold-text {
    color: var(--gold-primary);
}

/* Control Groups & Inputs */
.control-group {
    margin-bottom: 1.5rem;
}

.control-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-light);
    margin-bottom: 0.6rem;
}

.badge {
    background: rgba(212, 175, 55, 0.12);
    color: var(--gold-light);
    font-size: 0.75rem;
    padding: 2px 8px;
    border-radius: 4px;
    border: 1px solid rgba(212, 175, 55, 0.25);
}

.text-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-family: var(--font-ui);
    font-size: 0.8rem;
    cursor: pointer;
    transition: color var(--transition-speed);
}

.text-btn:hover {
    color: var(--gold-light);
    text-decoration: underline;
}

/* Input Fields */
.input-wrapper {
    position: relative;
    width: 100%;
}

.input-icon {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 1.1rem;
    transition: color var(--transition-speed);
}

.input-wrapper input[type="text"] {
    width: 100%;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    padding: 12px 42px 12px 14px;
    color: #ffffff;
    font-family: var(--font-ui);
    font-size: 1.1rem;
    outline: none;
    transition: all var(--transition-speed);
    text-align: right;
}

.input-wrapper input[type="text"]:focus {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--gold-primary);
    box-shadow: 0 0 10px rgba(212, 175, 55, 0.15);
}

.input-wrapper input[type="text"]:focus + .input-icon {
    color: var(--gold-primary);
}

/* Select Dropdown */
.select-wrapper {
    position: relative;
    width: 100%;
}

.select-icon {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}

select {
    width: 100%;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    padding: 12px 42px 12px 14px;
    color: var(--text-light);
    font-family: var(--font-ui);
    font-size: 0.95rem;
    outline: none;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    transition: all var(--transition-speed);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23a0a0aa' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: left 14px center;
    background-size: 16px;
}

select:focus {
    border-color: var(--gold-primary);
    background-color: #1a1a20;
    box-shadow: 0 0 10px rgba(212, 175, 55, 0.15);
}

/* Color Palette Select */
.color-palette-options {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.color-preset {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,0.15);
    cursor: pointer;
    transition: transform 0.2s, border-color 0.2s;
    position: relative;
    outline: none;
}

.color-preset:hover {
    transform: scale(1.1);
}

.color-preset.active {
    border-color: var(--gold-primary);
    transform: scale(1.15);
    box-shadow: 0 0 12px rgba(212, 175, 55, 0.4);
}

.color-preset.active::after {
    content: "\f00c";
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #000;
    text-shadow: 0 0 2px #fff;
    font-size: 0.8rem;
}

.color-preset[data-color="#ffffff"].active::after {
    color: #000;
    text-shadow: none;
}

.custom-color-picker-wrapper {
    position: relative;
    width: 38px;
    height: 38px;
}

.custom-color-picker-wrapper input[type="color"] {
    position: absolute;
    opacity: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
}

.custom-color-picker-wrapper label {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: linear-gradient(45deg, red, orange, yellow, green, blue, purple);
    border: 2px solid rgba(255,255,255,0.15);
    cursor: pointer;
    color: #fff;
    font-size: 0.9rem;
    transition: transform var(--transition-speed);
}

.custom-color-picker-wrapper:hover label {
    transform: scale(1.1);
}

.custom-color-picker-wrapper.active label {
    border-color: var(--gold-primary);
    box-shadow: 0 0 12px rgba(212, 175, 55, 0.4);
}

/* Control Row - Size and Weight */
.control-row {
    display: flex;
    gap: 1.2rem;
}

.half-width {
    flex: 1;
}

/* Custom Range Sliders */
.range-wrapper {
    display: flex;
    align-items: center;
    height: 46px;
}

input[type="range"] {
    -webkit-appearance: none;
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.1);
    outline: none;
    cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--gold-primary);
    box-shadow: 0 0 8px var(--gold-glow);
    transition: transform 0.1s, background 0.1s;
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    background: var(--gold-light);
}

/* Nudge Alignment CSS */
.nudge-controls {
    background: rgba(255,255,255,0.02);
    border: 1px solid rgba(255,255,255,0.05);
    border-radius: 10px;
    padding: 12px 16px;
}

.nudge-slider {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.nudge-slider:last-child {
    margin-bottom: 0;
}

.nudge-slider span {
    font-size: 0.85rem;
    color: var(--text-muted);
    min-width: 45px;
}

.nudge-slider .numeric-val {
    min-width: 25px;
    text-align: left;
    font-family: 'Outfit', sans-serif;
    color: var(--gold-light);
    font-weight: 600;
}

/* Primary Button Styling */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    width: 100%;
    padding: 14px 24px;
    border-radius: 12px;
    font-family: var(--font-ui);
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    outline: none;
    border: none;
    transition: all var(--transition-speed);
}

.btn-primary {
    background: linear-gradient(135deg, var(--gold-primary) 0%, var(--gold-dark) 100%);
    color: #0b0b0d;
    box-shadow: 0 4px 15px rgba(212, 175, 55, 0.2);
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--gold-light) 0%, var(--gold-primary) 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(212, 175, 55, 0.35);
}

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

.btn-secondary {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-light);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--gold-primary);
    color: var(--gold-light);
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(212, 175, 55, 0.1);
}

.btn-secondary:active {
    transform: translateY(1px);
}

.action-buttons-group {
    display: flex;
    gap: 12px;
    margin-bottom: 1rem;
}

.action-buttons-group .btn {
    flex: 1;
}

.btn-glowing {
    position: relative;
    overflow: hidden;
}

.btn-glowing::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 50%;
    height: 100%;
    background: linear-gradient(
        to right,
        rgba(255, 255, 255, 0) 0%,
        rgba(255, 255, 255, 0.3) 50%,
        rgba(255, 255, 255, 0) 100%
    );
    transform: skewX(-25deg);
    transition: 0.75s;
}

.btn-glowing:hover::before {
    animation: shine 1.5s infinite;
}

@keyframes shine {
    100% {
        left: 125%;
    }
}

.notes-container {
    margin-top: 1.2rem;
    padding: 10px 12px;
    border-radius: 8px;
    background: rgba(255,255,255,0.02);
    border-right: 3px solid var(--gold-primary);
}

.notes-container p {
    font-size: 0.8rem;
    color: var(--text-muted);
    line-height: 1.5;
}

.notes-container i {
    color: var(--gold-primary);
    margin-left: 4px;
}

/* Preview Panel */
.preview-panel {
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

.preview-container {
    width: 100%;
    max-width: 440px;
    display: flex;
    flex-direction: column;
}

.preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    padding-bottom: 0.6rem;
}

.preview-title {
    font-weight: 700;
    font-size: 1.05rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.preview-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.75rem;
    background: rgba(46, 213, 115, 0.1);
    color: #2ed573;
    padding: 3px 8px;
    border-radius: 20px;
    font-weight: 700;
    border: 1px solid rgba(46, 213, 115, 0.2);
}

.pulse-dot {
    width: 6px;
    height: 6px;
    background-color: #2ed573;
    border-radius: 50%;
    box-shadow: 0 0 6px #2ed573;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% { transform: scale(0.9); opacity: 0.8; }
    50% { transform: scale(1.3); opacity: 1; box-shadow: 0 0 10px #2ed573; }
    100% { transform: scale(0.9); opacity: 0.8; }
}

/* Video Ratio Box (9:16 aspect ratio wrapper) */
.video-ratio-box {
    position: relative;
    width: 100%;
    aspect-ratio: 9 / 16;
    background-color: #050507;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6);
    border: 1px solid rgba(255,255,255,0.05);
}

.video-wrapper {
    width: 100%;
    height: 100%;
    position: relative;
    /* Setup container query on the wrapper to enable scaling text overlay */
    container-type: size;
}

.video-wrapper video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Overlay Bounding Box */
.video-overlay {
    position: absolute;
    /* Matches coordinates: left: 227px (21.02%), top: 1478px (76.98%), width: 626px (57.96%), height: 147px (7.66%) */
    left: 21.0185%;
    top: 76.9791%;
    width: 57.9629%;
    height: 7.65625%;
    pointer-events: none;
    z-index: 5;
    display: flex;
    justify-content: center;
    align-items: center;
}

.text-bounding-box {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    transform: translate(
        calc(var(--nudge-x, 0) / 1080 * 100cqw),
        calc(var(--nudge-y, 0) / 1080 * 100cqw)
    );
}

#overlayText {
    display: block;
    width: 100%;
    text-align: center;
    white-space: nowrap;
    overflow: visible;
    /* Default golden color */
    color: var(--gold-dark);
    font-weight: 700;
    /* CSS Container Query size scaling: default size is 38px in 1080px width, i.e., 3.52cqw */
    font-size: calc(var(--font-size-scale, 38) / 1080 * 100cqw);
    font-family: 'Amiri', serif;
    /* Subtle drop shadow to simulate depth */
    text-shadow: 0 1px 2px rgba(0,0,0,0.15);
    direction: rtl;
    line-height: 1.3;
}

/* Video Control Bar */
.video-controls {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 1rem;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.05);
    padding: 8px 14px;
    border-radius: 10px;
}

.control-btn {
    background: none;
    border: none;
    color: var(--text-light);
    cursor: pointer;
    font-size: 1rem;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background var(--transition-speed), color var(--transition-speed);
}

.control-btn:hover {
    background: rgba(255,255,255,0.08);
    color: var(--gold-light);
}

.progress-bar-wrapper {
    flex: 1;
    height: 6px;
    background: rgba(255,255,255,0.08);
    border-radius: 3px;
    overflow: hidden;
    cursor: pointer;
    position: relative;
}

.video-progress {
    height: 100%;
    width: 0%;
    background: var(--gold-primary);
    border-radius: 3px;
    transition: width 0.1s linear;
}

.video-time {
    font-family: 'Outfit', sans-serif;
    font-size: 0.8rem;
    color: var(--text-muted);
    direction: ltr;
}

/* Modal Styling */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(11, 11, 13, 0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s ease;
}

.modal.show {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    width: 90%;
    max-width: 460px;
    padding: 2.5rem 2rem;
    transform: scale(0.9);
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    border: 1px solid rgba(212, 175, 55, 0.3);
    box-shadow: 0 15px 45px rgba(212, 175, 55, 0.1);
}

.modal.show .modal-content {
    transform: scale(1);
}

.text-center {
    text-align: center;
}

/* Sheep Loader Animation */
.sheep-loader-container {
    position: relative;
    height: 110px;
    margin-bottom: 1.5rem;
    display: flex;
    justify-content: center;
    align-items: center;
}

.sheep-cloud {
    font-size: 5rem;
    color: rgba(255,255,255,0.06);
    position: absolute;
    z-index: 1;
}

.sheep-character {
    font-size: 3.5rem;
    position: relative;
    z-index: 2;
    animation: sheep-jump 1.8s ease-in-out infinite;
}

@keyframes sheep-jump {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    30% { transform: translateY(-20px) rotate(-5deg); }
    50% { transform: translateY(2px) rotate(5deg); }
    70% { transform: translateY(-10px) rotate(-2deg); }
    85% { transform: translateY(0) rotate(0deg); }
}

.gold-sparkles {
    position: absolute;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 3;
}

.gold-sparkles i {
    color: var(--gold-light);
    font-size: 1.2rem;
    position: absolute;
    animation: spin-sparkle 3s linear infinite;
    text-shadow: 0 0 6px var(--gold-glow);
}

.sparkle-1 {
    top: 15px;
    right: 30%;
    animation-delay: 0s;
}

.sparkle-2 {
    bottom: 15px;
    left: 30%;
    animation-delay: 1.5s;
}

@keyframes spin-sparkle {
    0% { transform: rotate(0deg) scale(0.6); opacity: 0.3; }
    50% { transform: rotate(180deg) scale(1.1); opacity: 1; }
    100% { transform: rotate(360deg) scale(0.6); opacity: 0.3; }
}

.modal-title {
    font-size: 1.4rem;
    font-weight: 700;
    margin-bottom: 0.8rem;
    color: #fff;
    background: linear-gradient(to left, #fff, var(--gold-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.modal-desc {
    font-size: 0.9rem;
    color: var(--text-muted);
    line-height: 1.6;
    margin-bottom: 1.8rem;
}

.modal-desc strong {
    color: var(--gold-light);
}

/* Modal Progress Bar */
.modal-progress-container {
    margin-bottom: 1.5rem;
}

.modal-progress-bar {
    width: 100%;
    height: 8px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 0.6rem;
    border: 1px solid rgba(255,255,255,0.03);
}

.modal-progress-fill {
    width: 0%;
    height: 100%;
    background: linear-gradient(to left, var(--gold-primary), var(--gold-light));
    border-radius: 4px;
    transition: width 0.1s linear;
}

.progress-stats {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    font-family: 'Outfit', sans-serif;
    color: var(--gold-light);
    font-weight: 600;
}

#modalProgressTime {
    font-family: var(--font-ui), sans-serif;
    color: var(--text-muted);
    font-weight: 400;
}

.modal-instructions {
    border-top: 1px solid rgba(255,255,255,0.08);
    padding-top: 1rem;
}

.modal-instructions p {
    font-size: 0.75rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.modal-instructions i {
    color: #e58e26;
}

/* Responsive Breakpoints */
@media (max-width: 900px) {
    .main-container {
        grid-template-columns: 1fr;
        gap: 2.5rem;
    }
    
    .preview-panel {
        order: -1; /* Display preview on top for mobile */
    }
    
    .preview-container {
        max-width: 360px;
    }
    
    .app-header {
        padding: 1.5rem 1rem 1rem;
    }
    
    .app-header h1 {
        font-size: 1.6rem;
    }
}

@media (max-width: 480px) {
    .glass-card {
        padding: 1.5rem 1.2rem;
    }
    
    .control-row {
        flex-direction: column;
        gap: 0;
    }
    
    .half-width {
        width: 100%;
    }
}
