/* ==========================================================================
   Random Number Generator - Zhween Tool
   ========================================================================== */

/* Override min-height from base template to prevent gap */
.tool-page-wrapper:has(.rn-container) {
    min-height: 0 !important;
    background: linear-gradient(135deg, #0f0c29 0%, #1a1a4e 40%, #24243e 100%) !important;
}

.tool-content-area:has(.rn-container) {
    min-height: 0 !important;
}

/* ---------- Container ---------- */
.rn-container {
    --rn-primary: #15aebf;
    --rn-primary-light: #4ecdc4;
    --rn-primary-dark: #0e9bb2;
    --rn-accent: #ffd93d;
    --rn-glow: rgba(21, 174, 191, 0.5);
    --rn-glow-accent: rgba(255, 217, 61, 0.4);
    --rn-bg-card: rgba(255, 255, 255, 0.06);
    --rn-bg-card-hover: rgba(255, 255, 255, 0.1);
    --rn-text: #ffffff;
    --rn-text-muted: rgba(255, 255, 255, 0.6);
    --rn-radius: 16px;
    --rn-radius-sm: 10px;
    --rn-transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);

    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 75vh;
    padding: 24px;
    gap: 24px;
    color: var(--rn-text);
    overflow: hidden;
}

/* ---------- Watermark ---------- */
.rn-watermark {
    position: absolute;
    bottom: 16px;
    right: 16px;
    width: 48px;
    height: 48px;
    opacity: 0.08;
    pointer-events: none;
    z-index: 0;
}

/* ---------- Display Area ---------- */
.rn-display-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    z-index: 1;
}

.rn-number-display {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 320px;
    height: 200px;
    background: var(--rn-bg-card);
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 24px;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow:
        0 0 40px rgba(21, 174, 191, 0.15),
        inset 0 1px 0 rgba(255, 255, 255, 0.08);
    transition: var(--rn-transition);
    overflow: hidden;
}

.rn-number-display::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 24px;
    background: radial-gradient(circle at 50% 30%, rgba(21, 174, 191, 0.08) 0%, transparent 70%);
    pointer-events: none;
}

.rn-number-display.rn-rolling {
    animation: rn-display-pulse 0.15s ease-in-out infinite alternate;
    border-color: var(--rn-primary);
    box-shadow:
        0 0 60px var(--rn-glow),
        0 0 120px rgba(21, 174, 191, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.rn-number-display.rn-result {
    border-color: var(--rn-accent);
    box-shadow:
        0 0 60px var(--rn-glow-accent),
        0 0 100px rgba(255, 217, 61, 0.15),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
    animation: rn-result-pop 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.rn-number {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    font-size: 96px;
    font-weight: 800;
    line-height: 1;
    letter-spacing: -2px;
    background: linear-gradient(180deg, #ffffff 0%, #e0e0e0 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: none;
    transition: font-size 0.3s ease;
    user-select: all;
}

.rn-number-display.rn-result .rn-number {
    background: linear-gradient(180deg, var(--rn-accent) 0%, #ffb800 100%);
    -webkit-background-clip: text;
    background-clip: text;
}

.rn-number.rn-small {
    font-size: 64px;
}

.rn-number.rn-xsmall {
    font-size: 48px;
}

.rn-number.rn-placeholder {
    font-size: 56px;
    opacity: 0.4;
}

.rn-range-label {
    font-size: 15px;
    font-weight: 600;
    color: var(--rn-text-muted);
    letter-spacing: 2px;
    text-transform: uppercase;
}

/* ---------- Controls ---------- */
.rn-controls {
    display: flex;
    align-items: center;
    gap: 12px;
    z-index: 1;
    flex-wrap: wrap;
    justify-content: center;
}

.rn-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    border: none;
    border-radius: var(--rn-radius-sm);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--rn-transition);
    user-select: none;
    white-space: nowrap;
    position: relative;
    overflow: hidden;
}

.rn-btn-icon {
    font-size: 18px;
    line-height: 1;
}

.rn-btn-generate {
    background: linear-gradient(135deg, var(--rn-primary) 0%, var(--rn-primary-light) 100%);
    color: #fff;
    padding: 16px 40px;
    font-size: 18px;
    border-radius: var(--rn-radius);
    box-shadow: 0 4px 20px var(--rn-glow);
}

.rn-btn-generate:hover {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 8px 30px var(--rn-glow);
}

.rn-btn-generate:active {
    transform: translateY(0) scale(0.98);
}

.rn-btn-generate.rn-spinning {
    pointer-events: none;
    opacity: 0.85;
}

.rn-btn-clear {
    background: var(--rn-bg-card);
    color: var(--rn-text);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.rn-btn-clear:hover {
    background: var(--rn-bg-card-hover);
    border-color: rgba(255, 255, 255, 0.2);
}

.rn-btn-settings {
    background: var(--rn-bg-card);
    color: var(--rn-text);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.rn-btn-settings:hover {
    background: var(--rn-bg-card-hover);
    border-color: rgba(255, 255, 255, 0.2);
}

.rn-btn-settings.rn-active {
    background: rgba(21, 174, 191, 0.15);
    border-color: var(--rn-primary);
    color: var(--rn-primary-light);
}

.rn-btn-sound {
    background: var(--rn-bg-card);
    color: var(--rn-text);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 12px 16px;
}

.rn-btn-sound:hover {
    background: var(--rn-bg-card-hover);
}

.rn-btn-sound.rn-muted {
    opacity: 0.5;
}

/* ---------- Settings Panel ---------- */
.rn-settings-panel {
    display: none;
    z-index: 2;
    width: 100%;
    max-width: 420px;
    animation: rn-slide-down 0.3s ease;
}

.rn-settings-panel.rn-open {
    display: block;
}

.rn-settings-content {
    background: var(--rn-bg-card);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--rn-radius);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.rn-settings-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--rn-text);
    margin: 0;
    text-align: center;
}

.rn-range-inputs {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    justify-content: center;
}

.rn-input-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
    max-width: 140px;
}

.rn-input-label {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--rn-text-muted);
}

.rn-input {
    width: 100%;
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: var(--rn-radius-sm);
    color: var(--rn-text);
    font-size: 18px;
    font-weight: 700;
    text-align: center;
    transition: var(--rn-transition);
    outline: none;
    box-sizing: border-box;
}

.rn-input:focus {
    border-color: var(--rn-primary);
    box-shadow: 0 0 0 3px rgba(21, 174, 191, 0.2);
}

.rn-input.rn-input-error {
    border-color: #e17055;
    box-shadow: 0 0 0 3px rgba(225, 112, 85, 0.2);
}

.rn-range-separator {
    font-size: 20px;
    font-weight: 700;
    color: var(--rn-text-muted);
    padding-bottom: 10px;
}

/* ---------- Presets ---------- */
.rn-presets {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
}

.rn-presets-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--rn-text-muted);
}

.rn-preset-btn {
    padding: 6px 14px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    color: var(--rn-text-muted);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--rn-transition);
}

.rn-preset-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    color: var(--rn-text);
}

.rn-preset-btn.rn-preset-active {
    background: rgba(21, 174, 191, 0.2);
    border-color: var(--rn-primary);
    color: var(--rn-primary-light);
}

.rn-btn-apply {
    background: linear-gradient(135deg, var(--rn-primary) 0%, var(--rn-primary-light) 100%);
    color: #fff;
    justify-content: center;
    box-shadow: 0 4px 15px var(--rn-glow);
}

.rn-btn-apply:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px var(--rn-glow);
}

/* ---------- History ---------- */
.rn-history {
    position: absolute;
    bottom: 16px;
    left: 16px;
    z-index: 1;
    max-width: 280px;
}

.rn-history-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.rn-history-title {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--rn-text-muted);
}

.rn-history-clear {
    background: none;
    border: none;
    color: var(--rn-text-muted);
    font-size: 14px;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    transition: var(--rn-transition);
    line-height: 1;
}

.rn-history-clear:hover {
    color: #e17055;
    background: rgba(225, 112, 85, 0.15);
}

.rn-history-items {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.rn-history-item {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    padding: 4px 10px;
    background: var(--rn-bg-card);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    font-size: 14px;
    font-weight: 700;
    color: var(--rn-text-muted);
    animation: rn-history-pop 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.rn-history-item:first-child {
    color: var(--rn-primary-light);
    border-color: rgba(21, 174, 191, 0.3);
    background: rgba(21, 174, 191, 0.1);
}

/* ---------- Animations ---------- */
@keyframes rn-display-pulse {
    from {
        box-shadow:
            0 0 40px var(--rn-glow),
            inset 0 1px 0 rgba(255, 255, 255, 0.1);
    }
    to {
        box-shadow:
            0 0 70px var(--rn-glow),
            0 0 120px rgba(21, 174, 191, 0.15),
            inset 0 1px 0 rgba(255, 255, 255, 0.1);
    }
}

@keyframes rn-result-pop {
    0% { transform: scale(0.9); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

@keyframes rn-slide-down {
    from {
        opacity: 0;
        transform: translateY(-12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes rn-history-pop {
    from {
        opacity: 0;
        transform: scale(0.6);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes rn-number-roll {
    0% { transform: translateY(0); opacity: 1; }
    25% { transform: translateY(-30%); opacity: 0.5; }
    50% { transform: translateY(20%); opacity: 0.7; }
    75% { transform: translateY(-10%); opacity: 0.9; }
    100% { transform: translateY(0); opacity: 1; }
}

.rn-number.rn-rolling-text {
    animation: rn-number-roll 0.1s ease-in-out;
}

/* ---------- Fullscreen ---------- */
:fullscreen .rn-container,
:-webkit-full-screen .rn-container,
:-moz-full-screen .rn-container {
    min-height: 100vh;
    justify-content: center;
    align-items: center;
}

:fullscreen .rn-number-display,
:-webkit-full-screen .rn-number-display,
:-moz-full-screen .rn-number-display {
    width: 440px;
    height: 280px;
}

:fullscreen .rn-number,
:-webkit-full-screen .rn-number,
:-moz-full-screen .rn-number {
    font-size: 130px;
}

:fullscreen .rn-number.rn-small,
:-webkit-full-screen .rn-number.rn-small,
:-moz-full-screen .rn-number.rn-small {
    font-size: 90px;
}

:fullscreen .rn-number.rn-xsmall,
:-webkit-full-screen .rn-number.rn-xsmall,
:-moz-full-screen .rn-number.rn-xsmall {
    font-size: 68px;
}

:fullscreen .rn-history,
:-webkit-full-screen .rn-history,
:-moz-full-screen .rn-history {
    position: absolute;
    bottom: 24px;
    left: 24px;
}

/* ---------- RTL ---------- */
[dir="rtl"] .rn-container {
    direction: rtl;
}

[dir="rtl"] .rn-history {
    left: auto;
    right: 16px;
}

[dir="rtl"] .rn-watermark {
    right: auto;
    left: 16px;
}

/* ---------- Responsive ---------- */
@media (max-width: 600px) {
    .rn-container {
        padding: 16px;
        gap: 18px;
        min-height: 65vh;
    }

    .rn-number-display {
        width: 260px;
        height: 160px;
    }

    .rn-number {
        font-size: 72px;
    }

    .rn-number.rn-small {
        font-size: 52px;
    }

    .rn-number.rn-xsmall {
        font-size: 38px;
    }

    .rn-btn {
        padding: 10px 18px;
        font-size: 14px;
    }

    .rn-btn-generate {
        padding: 14px 32px;
        font-size: 16px;
    }

    .rn-history {
        position: relative;
        bottom: auto;
        left: auto;
        max-width: 100%;
    }

    .rn-history-items {
        justify-content: center;
    }

    .rn-range-inputs {
        flex-direction: column;
        align-items: center;
    }

    .rn-range-separator {
        transform: rotate(90deg);
        padding: 0;
    }

    .rn-input-group {
        max-width: 180px;
    }
}

@media (max-width: 400px) {
    .rn-number-display {
        width: 220px;
        height: 140px;
    }

    .rn-number {
        font-size: 56px;
    }

    .rn-number.rn-small {
        font-size: 42px;
    }

    .rn-number.rn-xsmall {
        font-size: 32px;
    }

    .rn-controls {
        gap: 8px;
    }

    .rn-btn-text {
        display: none;
    }

    .rn-btn-generate .rn-btn-text {
        display: inline;
    }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
    .rn-number-display,
    .rn-number-display.rn-rolling,
    .rn-number-display.rn-result,
    .rn-number.rn-rolling-text,
    .rn-history-item,
    .rn-settings-panel,
    .rn-btn {
        animation: none !important;
        transition: none !important;
    }
}
