/* Enhanced CSS with better organization and responsive design */

/* CSS Variables for consistent theming */
:root {
    --primary-color: #007bff;
    --primary-hover: #0056b3;
    --secondary-color: #6c757d;
    --success-color: #28a745;
    --warning-color: #ffc107;
    --danger-color: #dc3545;
    --info-color: #17a2b8;

    --bg-light: #f8f9fa;
    --bg-white: #ffffff;
    --border-color: #dee2e6;
    --text-color: #333333;
    --text-muted: #6c757d;

    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 8px rgba(0, 0, 0, 0.15);
    --shadow-lg: 0 8px 32px rgba(31, 38, 135, 0.37);

    --border-radius: 8px;
    --border-radius-lg: 16px;
    --transition: all 0.3s ease;

    --font-family: 'Vazirmatn', sans-serif;
    --font-size-sm: 14px;
    --font-size-base: 16px;
    --font-size-lg: 18px;
    --font-size-xl: 24px;
}

/* Reset and base styles */
* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-family);
    text-align: center;
    color: var(--text-color);
    margin: 0;
    padding: 20px;
    background: linear-gradient(-45deg, #ee7752, #e73c7e, #23a6d5, #23d5ab);
    background-size: 400% 400%;
    animation: gradientBG 15s ease infinite;
    min-height: 100vh;
}

@keyframes gradientBG {
    0% {
        background-position: 0% 50%;
    }

    50% {
        background-position: 100% 50%;
    }

    100% {
        background-position: 0% 50%;
    }
}

/* Main container */
.container {
    max-width: 1200px;
    margin: 20px auto;
    background: rgba(255, 255, 255, 0.97);
    backdrop-filter: blur(10px);
    padding: 30px;
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-lg);
    border: 1px solid rgba(255, 255, 255, 0.18);
}

/* Typography */
h1 {
    margin-bottom: 25px;
    color: #1a237e;
    font-size: var(--font-size-xl);
    font-weight: bold;
}

h2 {
    color: var(--primary-color);
    margin-bottom: 20px;
}

h3 {
    color: var(--text-color);
    margin-bottom: 15px;
}

/* ============================================
   TAB NAVIGATION SYSTEM
   ============================================ */

.tabs-container {
    margin: 25px 0;
}

.tabs-nav {
    display: flex;
    gap: 8px;
    border-bottom: 2px solid var(--border-color);
    margin-bottom: 25px;
    overflow-x: auto;
    scrollbar-width: thin;
}

.tabs-nav::-webkit-scrollbar {
    height: 4px;
}

.tabs-nav::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 2px;
}

.tab-button {
    padding: 12px 24px;
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    color: var(--text-muted);
    font-size: var(--font-size-base);
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
}

.tab-button:hover {
    color: var(--primary-color);
    background: rgba(0, 123, 255, 0.05);
    transform: none;
    box-shadow: none;
}

.tab-button.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
    font-weight: 600;
}

.tab-button .tab-icon {
    font-size: 1.2em;
}

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

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

@keyframes fadeInTab {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

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

/* ============================================
   SECTION CARDS
   ============================================ */

.section-card {
    background: var(--bg-white);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 25px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

.section-card:hover {
    box-shadow: var(--shadow-md);
    border-color: rgba(0, 123, 255, 0.3);
}

.section-title {
    font-size: var(--font-size-lg);
    font-weight: 600;
    color: var(--text-color);
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.section-title .icon {
    font-size: 1.3em;
}

.section-description {
    color: var(--text-muted);
    font-size: var(--font-size-sm);
    margin-bottom: 20px;
}

/* Accordion/Details styling */
details {
    background: var(--bg-light);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    margin-bottom: 15px;
    transition: var(--transition);
    overflow: hidden;
}

details[open] {
    background: var(--bg-white);
    box-shadow: var(--shadow-sm);
}

details:hover {
    border-color: var(--primary-color);
}

summary {
    font-weight: bold;
    font-size: var(--font-size-lg);
    cursor: pointer;
    padding: 15px 20px;
    list-style: none;
    position: relative;
    background: linear-gradient(90deg, transparent, rgba(0, 123, 255, 0.05), transparent);
    transition: var(--transition);
}

summary:hover {
    background: linear-gradient(90deg, transparent, rgba(0, 123, 255, 0.1), transparent);
}

summary::before {
    content: '◀';
    position: absolute;
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
    transition: transform 0.3s ease;
    font-size: 0.8em;
    color: var(--primary-color);
}

details[open]>summary::before {
    transform: translateY(-50%) rotate(-90deg);
}

.details-content {
    padding: 0 20px 20px;
    animation: slideDown 0.3s ease;
}

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

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

/* Form controls */
.controls {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px 25px;
    align-items: flex-start;
}

.control-item {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.control-item.checkbox-control {
    flex-direction: row;
    align-items: center;
    gap: 10px;
}

.full-width {
    grid-column: 1 / -1;
}

label {
    margin-bottom: 5px;
    font-size: var(--font-size-sm);
    font-weight: 500;
    color: var(--text-color);
}

input,
select,
textarea {
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    width: 100%;
    font-family: var(--font-family);
    font-size: var(--font-size-base);
    transition: var(--transition);
    background: var(--bg-white);
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}

input:hover,
select:hover,
textarea:hover {
    border-color: var(--primary-hover);
}

/* Range input styling */
input[type="range"] {
    height: 6px;
    background: var(--bg-light);
    border-radius: 3px;
    padding: 0;
}

input[type="range"]::-webkit-slider-thumb {
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    border: 2px solid var(--bg-white);
    box-shadow: var(--shadow-sm);
}

input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    border: 2px solid var(--bg-white);
    box-shadow: var(--shadow-sm);
}

/* Color input styling */
input[type="color"] {
    height: 50px;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    padding: 0;
}

/* File input styling */
input[type="file"] {
    padding: 8px;
    background: var(--bg-light);
}

/* Checkbox styling */
input[type="checkbox"] {
    width: 20px;
    height: 20px;
    accent-color: var(--primary-color);
}

/* Radio Group Styling */
.radio-group {
    display: flex;
    gap: 20px;
    margin-top: 5px;
}

.radio-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-weight: normal;
    font-size: var(--font-size-base);
}

.radio-label input[type="radio"] {
    width: 18px;
    height: 18px;
    margin: 0;
    cursor: pointer;
}

/* Theme selector */
#themeSelector {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    margin-top: 10px;
    justify-content: center;
}

.theme-preview {
    cursor: pointer;
    border: 2px solid transparent;
    border-radius: var(--border-radius);
    padding: 8px;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 130px;
    background: var(--bg-white);
}

.theme-preview:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.theme-preview.selected {
    border-color: var(--primary-color);
    box-shadow: 0 0 15px rgba(0, 123, 255, 0.3);
    transform: translateY(-2px);
}

.theme-preview .colors {
    width: 100%;
    height: 45px;
    border-radius: var(--border-radius);
    display: flex;
    justify-content: center;
    align-items: center;
    border: 1px solid var(--border-color);
    margin-bottom: 8px;
}

.theme-preview .colors .text-sample {
    font-size: 20px;
    font-weight: bold;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.1);
}

.theme-preview .theme-name {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
}

/* Drop zones */
.drop-zone {
    border: 2px dashed var(--border-color);
    border-radius: var(--border-radius);
    padding: 20px;
    margin-top: 8px;
    cursor: pointer;
    transition: var(--transition);
    background: var(--bg-light);
    text-align: center;
    color: var(--text-muted);
}

.drop-zone:hover {
    border-color: var(--primary-color);
    background: rgba(0, 123, 255, 0.05);
    color: var(--primary-color);
}

.drop-zone.drag-over {
    border-color: var(--success-color);
    background: rgba(40, 167, 69, 0.1);
    color: var(--success-color);
    transform: scale(1.02);
}

/* Loading spinner */
.loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-color);
    border-radius: 50%;
    border-top-color: var(--primary-color);
    animation: spin 1s ease-in-out infinite;
    margin-right: 8px;
}

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

/* Buttons */
button {
    padding: 14px 35px;
    font-size: var(--font-size-lg);
    font-weight: 500;
    cursor: pointer;
    border: none;
    border-radius: var(--border-radius);
    background-color: var(--primary-color);
    color: white;
    transition: var(--transition);
    font-family: var(--font-family);
    position: relative;
    overflow: hidden;
}

button:hover {
    background-color: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

button:active {
    transform: translateY(0);
}

button:disabled {
    background-color: var(--secondary-color);
    cursor: not-allowed;
    transform: none;
}

/* Button variants */
.btn-secondary {
    background-color: var(--secondary-color);
}

.btn-secondary:hover {
    background-color: #5a6268;
}

.btn-success {
    background-color: var(--success-color);
}

.btn-success:hover {
    background-color: #218838;
}

.btn-danger {
    background-color: var(--danger-color);
}

.btn-danger:hover {
    background-color: #c82333;
}

/* Textarea */
textarea {
    width: 100%;
    min-height: 150px;
    margin: 10px 0 20px;
    padding: 15px;
    font-size: var(--font-size-base);
    resize: vertical;
    line-height: 1.5;
}

/* Preview section */
#preview {
    margin-top: 30px;
}

.preview-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 20px;
    margin: 20px 0;
}

.preview-container img {
    max-width: 220px;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-md);
    cursor: pointer;
    transition: var(--transition);
}

.preview-container img:hover {
    transform: scale(1.05);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary-color);
}

/* Lightbox */
.lightbox {
    display: none;
    position: fixed;
    z-index: 1000;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(5px);
}

.lightbox.show {
    display: flex;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.lightbox img {
    max-width: 90%;
    max-height: 90%;
    object-fit: contain;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
}

.lightbox .close {
    position: absolute;
    top: 30px;
    right: 40px;
    font-size: 50px;
    color: white;
    cursor: pointer;
    transition: var(--transition);
    z-index: 1001;
}

.lightbox .close:hover {
    color: var(--danger-color);
    transform: scale(1.1);
}

/* Progress bar */
.progress-bar {
    width: 100%;
    height: 8px;
    background: var(--bg-light);
    border-radius: 4px;
    overflow: hidden;
    margin: 10px 0;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), var(--info-color));
    border-radius: 4px;
    transition: width 0.3s ease;
}

/* ============================================
   FLOATING ACTION BUTTON
   ============================================ */

.fab {
    position: fixed;
    bottom: 30px;
    left: 30px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color), var(--info-color));
    color: white;
    border: none;
    box-shadow: 0 4px 20px rgba(0, 123, 255, 0.4);
    cursor: pointer;
    transition: var(--transition);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    padding: 0;
}

.fab:hover {
    transform: scale(1.1) translateY(-2px);
    box-shadow: 0 6px 30px rgba(0, 123, 255, 0.6);
}

.fab:active {
    transform: scale(0.95);
}

/* Responsive design */
@media (max-width: 768px) {
    .container {
        margin: 10px;
        padding: 20px;
    }

    .controls {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    #themeSelector {
        gap: 10px;
    }

    .theme-preview {
        width: 110px;
    }

    .preview-container img {
        max-width: 180px;
    }

    button {
        padding: 12px 25px;
        font-size: var(--font-size-base);
    }

    .tabs-nav {
        gap: 4px;
    }

    .tab-button {
        padding: 10px 16px;
        font-size: var(--font-size-sm);
    }

    .section-card {
        padding: 20px;
    }

    .fab {
        bottom: 20px;
        left: 20px;
        width: 50px;
        height: 50px;
        font-size: 20px;
    }
}

@media (max-width: 480px) {
    body {
        padding: 10px;
    }

    .container {
        padding: 15px;
    }

    h1 {
        font-size: 20px;
    }

    .theme-preview {
        width: 90px;
    }

    .theme-preview .colors {
        height: 35px;
    }

    .preview-container img {
        max-width: 150px;
    }

    .tab-button .tab-icon {
        font-size: 1em;
    }

    .tab-button {
        padding: 8px 12px;
    }
}

/* Accessibility improvements */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Focus indicators for keyboard navigation */
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
.theme-preview:focus-visible,
.tab-button:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    :root {
        --border-color: #000000;
        --text-color: #000000;
        --bg-light: #ffffff;
    }
}

/* Print styles */
@media print {
    body {
        background: white;
    }

    .container {
        box-shadow: none;
        border: 1px solid #000;
    }

    button,
    .fab {
        display: none;
    }
}