/**
 * Malayalam Text FX - Modern Design System
 * Primary Color: Navy Green (#2C5F2D)
 *
 * @package Malayalam_Text_FX
 * @since 1.1.0
 */

/* ===========================
   CSS Variables - Light Mode
   =========================== */
:root {
    /* Navy Green Color Palette */
    --primary: #2C5F2D;
    --primary-dark: #1e4220;
    --primary-light: #4a8a4c;
    --primary-pale: #e8f5e8;
    
    /* Neutral Colors */
    --white: #ffffff;
    --black: #000000;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    
    /* Semantic Colors */
    --success: #10b981;
    --warning: #f59e0b;
    --error: #ef4444;
    --info: #3b82f6;
    
    /* Applied Colors - Light Mode */
    --bg-primary: #ffffff;
    --bg-secondary: #f9fafb;
    --bg-tertiary: #f3f4f6;
    --text-primary: #111827;
    --text-secondary: #374151;
    --text-tertiary: #6b7280;
    --border: #e5e7eb;
    --shadow: rgba(0, 0, 0, 0.1);
    --shadow-lg: rgba(0, 0, 0, 0.15);
    --mtfx-surface: #ffffff;
    
    /* Typography */
    --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    --font-mono: 'SF Mono', Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace;
    
    /* Spacing Scale */
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.25rem;
    --space-6: 1.5rem;
    --space-8: 2rem;
    --space-10: 2.5rem;
    --space-12: 3rem;
    --space-16: 4rem;
    
    /* Border Radius */
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
    --radius-full: 9999px;
    
    /* Transitions */
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    
    /* Z-Index */
    --z-dropdown: 1000;
    --z-sticky: 1020;
    --z-fixed: 1030;
    --z-modal: 1040;
    --z-popover: 1050;
    --z-tooltip: 1060;
}

/* ===========================
   Dark Mode Variables
   =========================== */
[data-theme="dark"] {
    --bg-primary: #000000;
    --bg-secondary: #111827;
    --bg-tertiary: #1f2937;
    --text-primary: #f9fafb;
    --text-secondary: #d1d5db;
    --text-tertiary: #9ca3af;
    --border: #374151;
    --shadow: rgba(0, 0, 0, 0.5);
    --shadow-lg: rgba(0, 0, 0, 0.7);
    --primary-pale: rgba(44, 95, 45, 0.3);
    --mtfx-surface: #000000;
}

/* ===========================
   Base Styles
   =========================== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-sans);
    font-size: 16px;
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--bg-secondary);
    transition: var(--transition);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ===========================
   Typography
   =========================== */
h1, h2, h3, h4, h5, h6 {
    font-weight: 700;
    line-height: 1.2;
    color: var(--text-primary);
    margin-bottom: var(--space-4);
}

h1 { font-size: clamp(2rem, 5vw, 3rem); }
h2 { font-size: clamp(1.75rem, 4vw, 2.5rem); }
h3 { font-size: clamp(1.5rem, 3vw, 2rem); }
h4 { font-size: clamp(1.25rem, 2.5vw, 1.75rem); }
h5 { font-size: 1.125rem; }
h6 { font-size: 1rem; }

p {
    margin-bottom: var(--space-4);
    color: var(--text-secondary);
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: var(--transition);
}

a:hover {
    color: var(--primary-dark);
    text-decoration: underline;
}

/* ===========================
   Theme Toggle Button
   =========================== */
.theme-toggle {
    position: fixed;
    top: var(--space-4);
    right: var(--space-4);
    width: 48px;
    height: 48px;
    border-radius: var(--radius-full);
    background: var(--bg-primary);
    border: 2px solid var(--border);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px var(--shadow);
    transition: var(--transition);
    z-index: var(--z-fixed);
}

.theme-toggle:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px var(--shadow-lg);
}

.theme-toggle svg {
    width: 24px;
    height: 24px;
    fill: var(--primary);
    transition: var(--transition);
}

.theme-toggle:hover svg {
    transform: rotate(20deg);
}

/* Hide icons based on theme */
[data-theme="light"] .theme-toggle .moon-icon { display: none; }
[data-theme="dark"] .theme-toggle .sun-icon { display: none; }

/* ===========================
   Generator Layout
   =========================== */
.mtfx-generator-wrapper {
    max-width: 1400px;
    margin: 0 auto;
    padding: var(--space-6);
}

.mtfx-layout {
    display: grid;
    grid-template-columns: 380px 1fr;
    gap: var(--space-6);
    align-items: start;
}

/* ===========================
   Controls Panel
   =========================== */
.mtfx-controls-panel {
    background: var(--bg-primary);
    border-radius: var(--radius-xl);
    box-shadow: 0 4px 6px var(--shadow);
    position: sticky;
    top: var(--space-6);
    max-height: calc(100vh - var(--space-12));
    overflow-y: auto;
}

.mtfx-controls-inner {
    padding: var(--space-6);
}

/* Custom Scrollbar */
.mtfx-controls-panel::-webkit-scrollbar {
    width: 8px;
}

.mtfx-controls-panel::-webkit-scrollbar-track {
    background: var(--bg-tertiary);
    border-radius: var(--radius-full);
}

.mtfx-controls-panel::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: var(--radius-full);
}

.mtfx-controls-panel::-webkit-scrollbar-thumb:hover {
    background: var(--primary-dark);
}

/* ===========================
   Control Sections
   =========================== */
.mtfx-control-section {
    margin-bottom: var(--space-6);
    padding-bottom: var(--space-6);
    border-bottom: 1px solid var(--border);
}

.mtfx-control-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.mtfx-section-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--space-4);
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.mtfx-control-group {
    margin-bottom: var(--space-4);
}

.mtfx-control-group:last-child {
    margin-bottom: 0;
}

/* ===========================
   Form Controls
   =========================== */
.mtfx-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: var(--space-2);
}

.mtfx-value {
    font-weight: 600;
    color: var(--primary);
    font-family: var(--font-mono);
}

/* Input Fields */
.mtfx-textarea,
.mtfx-select,
.mtfx-number-input {
    width: 100%;
    padding: var(--space-3) var(--space-4);
    border: 2px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 0.9375rem;
    font-family: inherit;
    transition: var(--transition);
}

.mtfx-textarea:focus,
.mtfx-select:focus,
.mtfx-number-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-pale);
}

.mtfx-textarea {
    resize: vertical;
    min-height: 80px;
    font-family: inherit;
}

/* Range Sliders */
.mtfx-range {
    width: 100%;
    height: 8px;
    border-radius: var(--radius-full);
    background: var(--bg-tertiary);
    outline: none;
    -webkit-appearance: none;
}

.mtfx-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    border-radius: var(--radius-full);
    background: var(--primary);
    cursor: pointer;
    box-shadow: 0 2px 4px var(--shadow);
    transition: var(--transition);
}

.mtfx-range::-webkit-slider-thumb:hover {
    background: var(--primary-dark);
    transform: scale(1.1);
}

.mtfx-range::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: var(--radius-full);
    background: var(--primary);
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 4px var(--shadow);
    transition: var(--transition);
}

.mtfx-range::-moz-range-thumb:hover {
    background: var(--primary-dark);
    transform: scale(1.1);
}

/* Color Inputs */
.mtfx-color-input {
    width: 60px;
    height: 40px;
    border: 2px solid var(--border);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
}

.mtfx-color-input:hover {
    border-color: var(--primary);
    transform: scale(1.05);
}

/* Checkboxes */
.mtfx-checkbox {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    accent-color: var(--primary);
}

/* ===========================
   Buttons
   =========================== */
.mtfx-btn,
.mtfx-btn-primary,
.mtfx-btn-secondary,
.mtfx-btn-sm {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-6);
    border: none;
    border-radius: var(--radius-md);
    font-size: 0.9375rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
}

.mtfx-btn-primary {
    background: var(--primary);
    color: white;
    box-shadow: 0 2px 4px var(--shadow);
}

.mtfx-btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px var(--shadow-lg);
}

.mtfx-btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 2px solid var(--border);
}

.mtfx-btn-secondary:hover {
    background: var(--bg-secondary);
    border-color: var(--primary);
    color: var(--primary);
}

.mtfx-btn-sm {
    padding: var(--space-2) var(--space-4);
    font-size: 0.875rem;
}

/* ===========================
   Preview Panel
   =========================== */
.mtfx-preview-panel {
    background: var(--bg-primary);
    border-radius: var(--radius-xl);
    box-shadow: 0 4px 6px var(--shadow);
    padding: var(--space-6);
}

.mtfx-preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-6);
    flex-wrap: wrap;
    gap: var(--space-4);
}

.mtfx-preview-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.mtfx-preview-actions {
    display: flex;
    gap: var(--space-3);
}

/* ===========================
   Canvas
   =========================== */
.mtfx-canvas-wrapper {
    background: linear-gradient(45deg, var(--gray-100) 25%, transparent 25%), 
                linear-gradient(-45deg, var(--gray-100) 25%, transparent 25%),
                linear-gradient(45deg, transparent 75%, var(--gray-100) 75%),
                linear-gradient(-45deg, transparent 75%, var(--gray-100) 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
    border-radius: var(--radius-lg);
    padding: var(--space-6);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 400px;
    box-shadow: inset 0 2px 4px var(--shadow);
}

[data-theme="dark"] .mtfx-canvas-wrapper {
    background: linear-gradient(45deg, var(--gray-800) 25%, transparent 25%), 
                linear-gradient(-45deg, var(--gray-800) 25%, transparent 25%),
                linear-gradient(45deg, transparent 75%, var(--gray-800) 75%),
                linear-gradient(-45deg, transparent 75%, var(--gray-800) 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
}

#mtfx-canvas {
    max-width: 100%;
    height: auto;
    box-shadow: 0 4px 12px var(--shadow-lg);
    border-radius: var(--radius-md);
}

.mtfx-preview-footer {
    margin-top: var(--space-4);
    text-align: center;
}

.mtfx-canvas-info {
    font-size: 0.875rem;
    color: var(--text-tertiary);
    font-family: var(--font-mono);
}

/* ===========================
   Accordion FAQ
   =========================== */
.mtfx-faq-section {
    margin-top: var(--space-12);
    padding: var(--space-8);
    background: var(--bg-primary);
    border-radius: var(--radius-xl);
    box-shadow: 0 4px 6px var(--shadow);
}

.mtfx-faq-section h2 {
    text-align: center;
    color: var(--primary);
    margin-bottom: var(--space-8);
}

.mtfx-faq-grid {
    max-width: 900px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
}

.mtfx-faq-item {
    border: 2px solid var(--border);
    border-radius: var(--radius-lg);
    margin-bottom: var(--space-4);
    overflow: hidden;
    transition: var(--transition);
    background: var(--mtfx-surface);
}

.mtfx-faq-item:hover {
    border-color: var(--primary);
    box-shadow: 0 2px 8px var(--shadow);
}

.mtfx-faq-question {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-5) var(--space-6);
    background: var(--bg-secondary);
    cursor: pointer;
    font-size: 1.0625rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
    transition: var(--transition);
    user-select: none;
}

.mtfx-faq-question:hover {
    background: var(--primary-pale);
    color: var(--primary-dark);
}

.mtfx-faq-icon {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--primary);
    transition: transform 0.3s ease;
    line-height: 1;
    flex-shrink: 0;
}

.mtfx-faq-item.active .mtfx-faq-icon {
    transform: rotate(45deg);
}

.mtfx-faq-answer {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease, padding 0.3s ease;
    background: var(--mtfx-surface);
}

.mtfx-faq-item.active .mtfx-faq-answer {
    max-height: 600px;
    padding: var(--space-5) var(--space-6);
    border-top: 2px solid var(--border);
}

.mtfx-faq-answer p {
    color: var(--text-secondary);
    line-height: 1.8;
    margin: 0;
    font-size: 0.9375rem;
}

/* Dark mode specific FAQ styling for better visibility */
[data-theme="dark"] .mtfx-faq-question {
    color: var(--text-primary);
}

[data-theme="dark"] .mtfx-faq-question:hover {
    color: var(--primary-light);
}

[data-theme="dark"] .mtfx-faq-answer p {
    color: var(--text-secondary);
}

/* ===========================
   Responsive Design
   =========================== */
@media (max-width: 1024px) {
    .mtfx-layout {
        grid-template-columns: 1fr;
    }
    
    .mtfx-controls-panel {
        position: static;
        max-height: none;
    }
}

@media (max-width: 768px) {
    .mtfx-generator-wrapper {
        padding: var(--space-4);
    }
    
    .mtfx-preview-header {
        flex-direction: column;
        align-items: stretch;
    }
    
    .mtfx-preview-actions {
        flex-direction: column;
    }
    
    .theme-toggle {
        top: var(--space-3);
        right: var(--space-3);
        width: 40px;
        height: 40px;
    }
    
    .theme-toggle svg {
        width: 20px;
        height: 20px;
    }
}

@media (max-width: 480px) {
    .mtfx-controls-inner,
    .mtfx-preview-panel {
        padding: var(--space-4);
    }
    
    .mtfx-faq-section {
        padding: var(--space-4);
    }
}

/* ===========================
   Loading Animation
   =========================== */
.mtfx-loading {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 400px;
}

.mtfx-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--border);
    border-top-color: var(--primary);
    border-radius: var(--radius-full);
    animation: spin 1s linear infinite;
}

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

/* ===========================
   Alerts
   =========================== */
.mtfx-status {
    position: fixed;
    top: var(--space-6);
    right: var(--space-6);
    z-index: var(--z-popover);
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    max-width: 400px;
}

.mtfx-alert {
    padding: var(--space-4) var(--space-5);
    border-radius: var(--radius-md);
    background: white;
    box-shadow: 0 4px 12px var(--shadow-lg);
    border-left: 4px solid;
    animation: slideIn 0.3s ease;
}

.mtfx-alert-success { border-left-color: var(--success); }
.mtfx-alert-error { border-left-color: var(--error); }
.mtfx-alert-warning { border-left-color: var(--warning); }
.mtfx-alert-info { border-left-color: var(--info); }

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* ===========================
   Accessibility
   =========================== */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* ===========================
   Print Styles
   =========================== */
@media print {
    .theme-toggle,
    .mtfx-controls-panel,
    .mtfx-preview-header,
    .mtfx-status {
        display: none !important;
    }
    
    .mtfx-canvas-wrapper {
        background: white !important;
    }
}