/* ═══════════════════════════════════════════════════════════════
   V6.3 NEW FEATURES - CSS
   ═══════════════════════════════════════════════════════════════ */

/* Accordion / Collapsible Sections */
.accordion-section {
    margin-bottom: 15px;
    border: 1px solid #ddd;
    border-radius: 8px;
    overflow: hidden;
    transition: all 0.3s;
}

.accordion-header {
    background: linear-gradient(135deg, #f0f8ff 0%, #e6f3ff 100%);
    padding: 15px 20px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    user-select: none;
    transition: all 0.3s;
    border-bottom: 1px solid transparent;
}

.accordion-header:hover {
    background: linear-gradient(135deg, #e6f3ff 0%, #d9ecff 100%);
}

.accordion-header.active {
    background: linear-gradient(135deg, #2d7d9a 0%, #1e5a75 100%);
    color: white;
    border-bottom-color: #2d7d9a;
}

.accordion-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    font-size: 16px;
    margin: 0;
}

.accordion-icon {
    font-size: 20px;
    transition: transform 0.3s;
}

.accordion-header.active .accordion-icon {
    transform: rotate(180deg);
}

.accordion-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s ease-out, padding 0.3s;
    padding: 0 20px;
    background: white;
}

.accordion-content.active {
    max-height: 2000px;
    padding: 20px;
    transition: max-height 0.5s ease-in, padding 0.3s;
}

/* Header Controls (Dark Mode + Undo/Redo) */
.header-controls {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
}


.icon-btn {
    background: #f0f0f0;
    border: 2px solid #ddd;
    padding: 8px 15px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s;
    font-weight: 500;
}

.icon-btn:hover:not(:disabled) {
    background: #e0e0e0;
    border-color: #ccc;
    transform: translateY(-2px);
}

.icon-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.undo-redo-controls {
    display: flex;
    gap: 5px;
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.loading-content {
    background: white;
    padding: 40px;
    border-radius: 20px;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.spinner {
    border: 6px solid #f3f3f3;
    border-top: 6px solid #667eea;
    border-radius: 50%;
    width: 60px;
    height: 60px;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px auto;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-text {
    font-size: 1.3em;
    font-weight: bold;
    color: #333;
    margin-bottom: 10px;
}

.loading-subtext {
    color: #666;
    font-size: 0.9em;
}

/* Download Section */
.download-section {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 12px;
    border: 2px solid #e0e0e0;
}

.download-section h3 {
    color: #333;
    margin-bottom: 15px;
    text-align: center;
}

/* Dark Mode Styles */
body.dark-mode {
    background: linear-gradient(135deg, #1e1e2e 0%, #2d2d44 100%);
}

body.dark-mode .container {
    background: rgba(40, 40, 60, 0.95);
    color: #e0e0e0;
}

body.dark-mode h1,
body.dark-mode h3,
body.dark-mode h4 {
    color: #f0f0f0;
}

body.dark-mode .subtitle {
    color: #b0b0b0;
}

body.dark-mode .control-group {
    background: rgba(60, 60, 80, 0.6) !important;
    color: #e0e0e0;
}

body.dark-mode .tab-button {
    background: rgba(60, 60, 80, 0.6);
    color: #e0e0e0;
    border-color: #555;
}

body.dark-mode .tab-button.active {
    background: rgba(100, 100, 120, 0.8);
    border-bottom-color: transparent;
}

body.dark-mode .upload-area {
    background: rgba(60, 60, 80, 0.6);
    border-color: #555;
    color: #e0e0e0;
}

body.dark-mode .text-editor-area textarea {
    background: rgba(30, 30, 40, 0.9);
    color: #e0e0e0;
    border-color: #555;
}

body.dark-mode .editor-info {
    background: rgba(60, 60, 80, 0.6);
    color: #e0e0e0;
}

body.dark-mode .status {
    background: rgba(60, 60, 80, 0.8);
}

body.dark-mode .instructions {
    background: rgba(60, 60, 80, 0.6);
    border-left-color: #ffc107;
    color: #e0e0e0;
}

/* Dark mode accordion styles */
body.dark-mode .accordion-section {
    border-color: #555;
}

body.dark-mode .accordion-header {
    background: linear-gradient(135deg, rgba(60, 60, 80, 0.8) 0%, rgba(50, 50, 70, 0.8) 100%);
    color: #e0e0e0;
}

body.dark-mode .accordion-header:hover {
    background: linear-gradient(135deg, rgba(70, 70, 90, 0.9) 0%, rgba(60, 60, 80, 0.9) 100%);
}

body.dark-mode .accordion-header.active {
    background: linear-gradient(135deg, #2d7d9a 0%, #1e5a75 100%);
    color: white;
}

body.dark-mode .accordion-content {
    background: rgba(40, 40, 60, 0.6);
    color: #e0e0e0;
}


body.dark-mode label,
body.dark-mode p,
body.dark-mode em {
    color: #d0d0d0;
}

body.dark-mode .icon-btn {
    background: rgba(60, 60, 80, 0.8);
    border-color: #555;
    color: #e0e0e0;
}

body.dark-mode .icon-btn:hover:not(:disabled) {
    background: rgba(80, 80, 100, 0.8);
}

body.dark-mode .download-section {
    background: rgba(60, 60, 80, 0.6);
    border-color: #555;
}

body.dark-mode .loading-content {
    background: rgba(40, 40, 60, 0.98);
    color: #e0e0e0;
}

body.dark-mode .loading-text {
    color: #f0f0f0;
}

body.dark-mode .loading-subtext {
    color: #b0b0b0;
}

/* Sticky Generate Button (Mobile) */
@media (max-width: 768px) {
    .btn-generate {
        position: sticky;
        bottom: 10px;
        z-index: 100;
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.3);
    }
}

/* Preview Size Optimization (Mobile) */
@media (max-width: 768px) {
    #previewCanvas {
        max-width: 100% !important;
        height: auto !important;
        object-fit: contain;
    }
    
    .preview {
        overflow-x: hidden;
        padding: 10px;
    }
}

/* Touch-Friendly Slider Controls */
.slider-control {
    display: flex;
    align-items: center;
    gap: 10px;
}

.slider-btn {
    background: #667eea;
    color: white;
    border: none;
    width: 35px;
    height: 35px;
    border-radius: 8px;
    font-size: 1.5em;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
    font-weight: bold;
    line-height: 1;
}

.slider-btn:hover {
    background: #5568d3;
    transform: scale(1.1);
}

.slider-btn:active {
    transform: scale(0.95);
}

body.dark-mode .slider-btn {
    background: #5568d3;
}

body.dark-mode .slider-btn:hover {
    background: #4557c2;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 900px;
    margin: 0 auto;
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    padding: 40px;
}

h1 {
    text-align: center;
    color: #333;
    margin-bottom: 10px;
    font-size: 2.5em;
}

.subtitle {
    text-align: center;
    color: #555;
    margin-bottom: 40px;
    font-size: 1.1em;
}


/* UI ENHANCEMENTS: Better Color Contrast */
.subtitle {
    text-align: center;
    color: #555;  /* Improved from #666 for better contrast */
    margin-bottom: 40px;
    font-size: 1.1em;
}

/* Better focus indicators for accessibility */
button:focus,
input:focus,
select:focus,
textarea:focus {
    outline: 3px solid #667eea;
    outline-offset: 2px;
}

.tab-button:focus {
    outline: 3px solid #667eea;
    outline-offset: -3px;
}


.upload-area {
    border: 3px dashed #667eea;
    border-radius: 15px;
    padding: 60px 20px;
    text-align: center;
    background: #f8f9ff;
    cursor: pointer;
    transition: all 0.3s;
    margin-bottom: 30px;
}

.upload-area:hover {
    border-color: #764ba2;
    background: #f0f2ff;
}

.upload-area.dragover {
    border-color: #4CAF50;
    background: #e8f5e9;
}

.upload-icon {
    font-size: 4em;
    margin-bottom: 20px;
}

input[type="file"] {
    display: none;
}

.controls {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.control-group {
    background: #f5f5f5;
    padding: 15px;
    border-radius: 10px;
}

label {
    display: block;
    margin-bottom: 8px;
    color: #555;
    font-weight: bold;
    font-size: 0.9em;
}

input[type="number"],
input[type="color"],
select {
    width: 100%;
    padding: 10px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 1em;
}

.btn {
    width: 100%;
    padding: 18px;
    font-size: 1.2em;
    font-weight: bold;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s;
    margin-bottom: 15px;
}

.btn-generate {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-generate:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(102, 126, 234, 0.4);
}

.btn-generate:disabled {
    background: #ccc !important;
    cursor: not-allowed !important;
    transform: none !important;
    box-shadow: none !important;
    opacity: 0.6;
}

.btn-download {
    background: #4CAF50;
    color: white;
    display: none;
}

.btn-download:hover {
    background: #45a049;
}

.preview {
    margin-top: 30px;
    text-align: center;
    display: none;
}

.preview h3 {
    margin-bottom: 20px;
    color: #333;
}

#previewCanvas {
    max-width: 100%;
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}

.status {
    padding: 15px;
    border-radius: 10px;
    margin-bottom: 20px;
    text-align: center;
    display: none;
}

.status.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.status.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.status.info {
    background: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

.instructions {
    background: #fff3cd;
    padding: 20px;
    border-radius: 10px;
    margin-top: 30px;
    border-left: 5px solid #ffc107;
}

.instructions h3 {
    margin-bottom: 10px;
    color: #856404;
}

.instructions ol {
    margin-left: 20px;
    color: #856404;
}

.instructions li {
    margin-bottom: 8px;
}

@media (max-width: 768px) {
    .container {
        padding: 20px;
    }
    
    h1 {
        font-size: 1.8em;
    }
    
    .controls {
        grid-template-columns: 1fr;
    }
}

/* --------------------------------------------------------------- */
/*                    V6 NEW FEATURES - TEXT EDITOR               */
/* --------------------------------------------------------------- */

/* Tabs */
.input-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    border-bottom: 2px solid #e0e0e0;
    padding-bottom: 0;
}

.tab-button {
    padding: 12px 24px;
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    font-size: 16px;
    color: #555;
    transition: all 0.3s ease;
    font-weight: 500;
    position: relative;
    bottom: -2px;
}

.tab-button:hover {
    color: #2d7d9a;
    background: #f8f9fa;
}

.tab-button.active {
    color: #2d7d9a;
    border-bottom-color: #2d7d9a;
    font-weight: 600;
}

/* Tab Content */
.tab-content {
    display: none;
    animation: fadeIn 0.3s ease;
}

.tab-content.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Text Editor Area */
.text-editor-area {
    background: white;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    margin-bottom: 20px;
}

.editor-header {
    margin-bottom: 15px;
}

.editor-header h3 {
    margin: 0 0 5px 0;
    color: #2d7d9a;
}

.editor-header p {
    margin: 0;
    color: #555;
    font-size: 14px;
}

/* Editor Toolbar */
.editor-toolbar {
    display: flex;
    gap: 15px;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 8px;
    margin-bottom: 15px;
    flex-wrap: wrap;
    align-items: center;
}

.editor-toolbar label {
    display: flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    padding: 5px 10px;
    border-radius: 4px;
    transition: background 0.2s ease;
}

.editor-toolbar label:hover {
    background: #e9ecef;
}

.editor-toolbar input[type="checkbox"] {
    cursor: pointer;
}

.toolbar-separator {
    color: #dee2e6;
    font-size: 18px;
    margin: 0 5px;
}

/* Text Editor Textarea */
#textEditor {
    width: 100%;
    min-height: 200px;
    padding: 15px;
    font-size: 16px;
    font-family: 'Georgia', 'Times New Roman', serif;
    line-height: 1.6;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    resize: vertical;
    transition: border-color 0.3s ease;
}

#textEditor:focus {
    outline: none;
    border-color: #2d7d9a;
    box-shadow: 0 0 0 3px rgba(45, 125, 154, 0.1);
}

/* Editor Info Bar */
.editor-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #e0e0e0;
    flex-wrap: wrap;
    gap: 10px;
}

.editor-info span {
    color: #555;
    font-size: 14px;
}

.editor-info strong {
    color: #2d7d9a;
    font-weight: 600;
}

/* Buttons */
.btn-small {
    padding: 8px 16px;
    background: #6c757d;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.3s ease;
}

.btn-small:hover {
    background: #5a6268;
}

.btn-primary {
    padding: 10px 24px;
    background: #2d7d9a;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    transition: all 0.3s ease;
}

.btn-primary:hover {
    background: #236577;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(45, 125, 154, 0.3);
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .input-tabs {
        flex-direction: column;
        gap: 0;
    }
    
    .tab-button {
        width: 100%;
        text-align: left;
        padding: 15px;
        border-bottom: 1px solid #e0e0e0;
        border-left: 3px solid transparent;
    }
    
    .tab-button.active {
        border-bottom-color: transparent;
        border-left-color: #2d7d9a;
        background: #f8f9fa;
    }
    
    .editor-toolbar {
        flex-direction: column;
        align-items: stretch;
    }
    
    .editor-toolbar label {
        justify-content: flex-start;
    }
    
    .editor-info {
        flex-direction: column;
        align-items: stretch;
    }
    
    .btn-primary,
    .btn-small {
        width: 100%;
    }
}

/* ========================================
   ENHANCED MOBILE RESPONSIVE DESIGN
   ======================================== */
@media (max-width: 768px) {
    /* Fix #1: Reduce excessive padding on mobile */
    body {
        padding: 10px !important;
    }
    
    .container {
        padding: 20px 15px !important;
        border-radius: 15px !important;
    }
    
    /* Fix #2: Scale down typography */
    h1 {
        font-size: 1.8em !important;
        margin-bottom: 8px !important;
    }
    
    .subtitle {
        font-size: 1em !important;
        margin-bottom: 25px !important;
    }
    
    /* Fix #3: Reduce upload area padding */
    .upload-area {
        padding: 30px 15px !important;
    }
    
    .upload-icon {
        font-size: 3em !important;
        margin-bottom: 15px !important;
    }
    
    .upload-area h3 {
        font-size: 1.2em !important;
        margin-bottom: 8px !important;
    }
    
    .upload-area p {
        font-size: 0.9em !important;
    }
    
    /* Fix #4: Single column layout for controls */
    .controls {
        grid-template-columns: 1fr !important;
        gap: 15px !important;
    }
    
    /* Fix #5: Reduce button sizing */
    .btn {
        font-size: 1em !important;
        padding: 15px !important;
    }
    
    /* Control groups - better spacing */
    .control-group {
        padding: 12px !important;
    }
    
    .control-group h4 {
        font-size: 1em !important;
    }
    
    /* Instructions section */
    .instructions {
        padding: 15px !important;
    }
    
    .instructions h3 {
        font-size: 1.1em !important;
    }
    
    .instructions ol {
        padding-left: 20px !important;
        font-size: 0.9em !important;
    }
    
    .instructions li {
        margin-bottom: 8px !important;
    }
    
    /* Status messages */
    .status {
        padding: 12px !important;
        font-size: 0.9em !important;
    }
    
    /* Animation controls */
    #animationControls {
        padding: 12px !important;
    }
    
    /* Range input labels */
    input[type="range"] + span {
        display: inline-block !important;
        min-width: 50px !important;
        font-size: 0.9em !important;
    }
    
    /* Tabs */
    .input-tabs {
        flex-direction: column;
        gap: 0;
    }

    .tab-button {
        width: 100%;
        text-align: left;
        padding: 15px;
        border-bottom: 1px solid #e0e0e0;
        border-left: 3px solid transparent;
    }

    .tab-button.active {
        border-bottom-color: transparent;
        border-left-color: #2d7d9a;
        background: #f8f9fa;
    }

    .editor-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .editor-toolbar label {
        justify-content: flex-start;
    }

    .editor-info {
        flex-direction: column;
        align-items: stretch;
    }

    .btn-primary,
    .btn-small {
        width: 100%;
    }
}

/* Tablet adjustments (between mobile and desktop) */
@media (min-width: 769px) and (max-width: 1024px) {
    .container {
        padding: 30px 25px !important;
    }
    
    h1 {
        font-size: 2.2em !important;
    }
    
    .controls {
        grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)) !important;
    }
}

