:root {
    --bg-dark: #0f172a;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --accent-primary: #818cf8;
    --accent-secondary: #c084fc;
    --accent-glow: rgba(129, 140, 248, 0.5);
    --glass-bg: rgba(30, 41, 59, 0.7);
    --glass-border: rgba(255, 255, 255, 0.08);
    --success: #34d399;
    --error: #f87171;
    --font-main: 'Outfit', sans-serif;
}

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

body {
    background-color: var(--bg-dark);
    color: var(--text-primary);
    font-family: var(--font-main);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow-x: hidden;
    position: relative;
}

/* Background Blobs */
.background-blobs {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    z-index: -1;
    overflow: hidden;
}

.blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.6;
    animation: blob-float 10s infinite alternate;
}

.blob-1 {
    width: 400px;
    height: 400px;
    background: var(--accent-primary);
    top: -100px;
    left: -100px;
}

.blob-2 {
    width: 300px;
    height: 300px;
    background: var(--accent-secondary);
    bottom: -50px;
    right: -50px;
    animation-delay: -5s;
}

.blob-3 {
    width: 250px;
    height: 250px;
    background: #2dd4bf;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    opacity: 0.3;
    animation: blob-pulse 8s infinite;
}

@keyframes blob-float {
    0% {
        transform: translate(0, 0);
    }

    100% {
        transform: translate(30px, 50px);
    }
}

@keyframes blob-pulse {
    0% {
        transform: translate(-50%, -50%) scale(1);
    }

    50% {
        transform: translate(-50%, -50%) scale(1.2);
    }

    100% {
        transform: translate(-50%, -50%) scale(1);
    }
}

/* Glass Container */
.glass-container {
    width: 90%;
    max-width: 500px;
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 2rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    animation: slide-up 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slide-up {
    from {
        opacity: 0;
        transform: translateY(40px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

header {
    text-align: center;
    margin-bottom: 2rem;
}

header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, #fff 0%, #cbd5e1 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 0.5rem;
}

header p {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

/* Tabs */
.tabs {
    display: flex;
    background: rgba(0, 0, 0, 0.2);
    padding: 4px;
    border-radius: 12px;
    margin-bottom: 2rem;
}

.tab-btn {
    flex: 1;
    padding: 10px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-family: inherit;
    font-weight: 600;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.3s ease;
}

.tab-btn.active {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.tab-content {
    display: none;
    animation: fade-in 0.3s ease;
}

.tab-content.active {
    display: block;
}

@keyframes fade-in {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Form Elements */
.input-group {
    margin-bottom: 1.5rem;
}

textarea {
    width: 100%;
    min-height: 150px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 1rem;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 1rem;
    resize: none;
    transition: all 0.3s ease;
}

textarea:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(129, 140, 248, 0.1);
    background: rgba(0, 0, 0, 0.3);
}

/* Settings Grid */
.settings-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 2rem;
}

.setting-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.setting-header {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 0.8rem;
}

/* Toggle Switch */
.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.1);
    transition: .4s;
    border-radius: 34px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked+.slider {
    background-color: var(--accent-primary);
}

input:checked+.slider:before {
    transform: translateX(20px);
}

/* Custom Select */
.custom-select {
    width: 100%;
    background: rgba(0, 0, 0, 0.2);
    color: #fff;
    border: 1px solid var(--glass-border);
    padding: 8px;
    border-radius: 8px;
    outline: none;
    cursor: pointer;
}

/* Buttons */
.cta-button {
    width: 100%;
    padding: 1rem;
    border: none;
    border-radius: 12px;
    font-family: inherit;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    position: relative;
    overflow: hidden;
}

.cta-button.primary {
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    color: #fff;
    box-shadow: 0 4px 12px rgba(129, 140, 248, 0.3);
}

.cta-button.primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(129, 140, 248, 0.4);
}

.cta-button.secondary {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    border: 1px solid var(--glass-border);
}

.cta-button.secondary:hover {
    background: rgba(255, 255, 255, 0.15);
}

.cta-button:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

/* Result Box */
.result-box {
    margin-top: 1.5rem;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 1.5rem;
    text-align: center;
    animation: slide-up 0.4s ease;
}

.result-box.hidden {
    display: none;
}

.code-display {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-top: 1rem;
    background: rgba(255, 255, 255, 0.05);
    padding: 1rem;
    border-radius: 12px;
}

#generated-code {
    font-size: 2.5rem;
    font-weight: 700;
    letter-spacing: 0.2rem;
    color: var(--success);
    font-variant-numeric: tabular-nums;
}

.copy-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    transition: color 0.2s;
    padding: 5px;
}

.copy-btn:hover {
    color: #fff;
}

/* View Section Inputs */
.huge-input {
    width: 100%;
    background: transparent;
    border: none;
    font-size: 3rem;
    text-align: center;
    color: #fff;
    font-weight: 700;
    letter-spacing: 0.5rem;
    padding: 1rem;
    border-bottom: 2px solid var(--glass-border);
    margin-bottom: 2rem;
    transition: border-color 0.3s;
}

.huge-input:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.huge-input::placeholder {
    color: rgba(255, 255, 255, 0.1);
}

.secret-content-wrapper {
    text-align: left;
    position: relative;
    max-height: 300px;
    overflow-y: auto;
}

#secret-text {
    font-family: inherit;
    white-space: pre-wrap;
    word-break: break-word;
    font-size: 1rem;
    line-height: 1.6;
}

.copy-text-btn {
    position: absolute;
    top: 0;
    right: 0;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: #fff;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    cursor: pointer;
}

.system-msg {
    margin-top: 1rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-style: italic;
}

/* Toast Notification */
#toast-container {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
}

.toast {
    background: rgba(15, 23, 42, 0.9);
    color: #fff;
    padding: 12px 24px;
    border-radius: 50px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    margin-top: 10px;
    animation: toast-in 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(4px);
}

/* Form Elements */
.input-group {
    margin-bottom: 2rem;
    /* Increased to make room for counter */
    position: relative;
}

textarea {
    width: 100%;
    min-height: 150px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 1rem;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 1rem;
    resize: none;
    transition: all 0.3s ease;
}

/* Character Count */
#char-count {
    position: absolute;
    bottom: -20px;
    /* Moved outside */
    right: 5px;
    /* Moved to right */
    left: auto;
    /* Reset left */
    font-size: 0.85rem;
    color: var(--text-secondary);
    background: transparent;
    padding: 0;
    pointer-events: none;
}

/* Custom Select Styling */
.custom-select-wrapper {
    position: relative;
    user-select: none;
    width: 100%;
}

.custom-select-trigger {
    position: relative;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(0, 0, 0, 0.2);
    color: #fff;
    border: 1px solid var(--glass-border);
    padding: 10px 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.95rem;
}

.custom-select-trigger:hover {
    background: rgba(255, 255, 255, 0.05);
}

.arrow {
    font-size: 0.7rem;
    transition: transform 0.3s ease;
    color: var(--accent-primary);
}

.custom-select-wrapper.open .arrow {
    transform: rotate(180deg);
}

.custom-options {
    position: absolute;
    top: calc(100% + 5px);
    left: 0;
    width: 100%;
    max-height: 200px;
    /* Limit height */
    overflow-y: auto;
    /* Enable scroll */
    background: rgba(15, 23, 42, 0.95);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    z-index: 100;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(8px);
}

/* Scrollbar for options */
.custom-options::-webkit-scrollbar {
    width: 6px;
}

.custom-options::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

.custom-select-wrapper.open .custom-options {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.custom-option {
    padding: 10px 12px;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.custom-option:hover {
    background: rgba(129, 140, 248, 0.1);
    color: #fff;
}

.custom-option.selected {
    background: rgba(129, 140, 248, 0.2);
    color: var(--accent-primary);
    font-weight: 600;
}

@keyframes toast-in {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Loader */
.btn-loader {
    display: none;
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 0.8s linear infinite;
}

.loading .btn-loader {
    display: block;
}

.loading span {
    display: none;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Mobile adjustments */
@media (max-width: 600px) {
    .glass-container {
        width: 100%;
        min-height: 100vh;
        /* Allow it to grow */
        height: auto;
        border-radius: 0;
        border: none;
        max-width: none;
        display: flex;
        flex-direction: column;
        justify-content: center;
        padding-top: 4rem;
        /* Give some space if header is tall */
        margin: 0;
    }

    #generated-code {
        font-size: 2rem;
    }
}

/* Modal Styles */
#modal-overlay,
#modal-secret-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    z-index: 2000;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 1;
    transition: opacity 0.3s ease;
}

#modal-overlay.hidden,
#modal-secret-overlay.hidden {
    opacity: 0;
    pointer-events: none;
    visibility: hidden;
}

.modal {
    background: linear-gradient(145deg, rgba(30, 41, 59, 0.9), rgba(15, 23, 42, 0.95));
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 2.5rem;
    width: 90%;
    max-width: 400px;
    text-align: center;
    position: relative;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    transform: scale(1);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    flex-direction: column;
}

/* Secret Modal specific */
.secret-modal {
    max-width: 650px;
    /* Increased from 500px */
    width: 95%;
    /* Take up more space on mobile */
    max-height: 85vh;
    /* Limit height */
}

#modal-overlay.hidden .modal,
#modal-secret-overlay.hidden .modal {
    transform: scale(0.9);
}

.close-modal {
    position: absolute;
    top: 15px;
    right: 15px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 2rem;
    line-height: 1;
    cursor: pointer;
    transition: color 0.2s;
    z-index: 10;
}

.close-modal:hover {
    color: #fff;
}

.modal h2 {
    font-size: 1.8rem;
    margin-bottom: 0.5rem;
    color: #fff;
}

.modal p {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}

.modal-code-display {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

#modal-generated-code {
    font-size: 3rem;
    font-weight: 700;
    color: var(--success);
    letter-spacing: 0.2rem;
    text-shadow: 0 0 20px rgba(52, 211, 153, 0.3);
}

.secret-content-box {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 1.5rem;
    margin-top: 1rem;
    text-align: left;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    overflow: hidden;
    min-height: 100px;
}

#modal-secret-text {
    font-family: 'Outfit', sans-serif;
    /* Cleaner font than monospace */
    white-space: pre-wrap;
    word-break: break-word;
    font-size: 1.1rem;
    line-height: 1.8;
    color: var(--text-primary);
    overflow-y: auto;
    max-height: 50vh;
    padding-right: 5px;
}

/* RTL Support */
#modal-secret-text.rtl-text {
    direction: rtl;
    text-align: right;
    font-family: 'Tahoma', 'Outfit', sans-serif;
    /* Better fallback for Persian */
}

/* Scrollbar for secret text */
#modal-secret-text::-webkit-scrollbar {
    width: 6px;
}

#modal-secret-text::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

.secret-actions {
    margin-top: 1.5rem;
    width: 100%;
}

.modal-copy-btn {
    width: 100%;
    padding: 0.8rem;
    background: var(--accent-primary);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: all 0.2s;
}

.modal-copy-btn:hover {
    background: #6366f1;
    transform: translateY(-2px);
}

/* Progress bar for auto-close */
.progress-bar-container {
    width: 100%;
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    overflow: hidden;
    margin-top: 1rem;
}

.progress-bar-container.hidden {
    display: none;
}

.progress-bar {
    height: 100%;
    width: 100%;
    background: var(--success);
    transform-origin: left;
    animation: shrink 3s linear forwards;
}

@keyframes shrink {
    from {
        transform: scaleX(1);
    }

    to {
        transform: scaleX(0);
    }
}
