/* ==========================================
   Aqlama Speech to Text - Shadcn-Inspired Design
   ========================================== */

/* CSS Variables */
:root {
    --background: 0 0% 100%;
    --foreground: 240 10% 3.9%;
    --card: 0 0% 100%;
    --card-foreground: 240 10% 3.9%;
    --primary: 240 5.9% 10%;
    --primary-foreground: 0 0% 98%;
    --secondary: 240 4.8% 95.9%;
    --secondary-foreground: 240 5.9% 10%;
    --muted: 240 4.8% 95.9%;
    --muted-foreground: 240 3.8% 46.1%;
    --accent: 240 4.8% 95.9%;
    --accent-foreground: 240 5.9% 10%;
    --border: 240 5.9% 90%;
    --input: 240 5.9% 90%;
    --ring: 240 5.9% 10%;
    --radius: 0.5rem;
    --success: 142 76% 36%;
    --error: 0 84% 60%;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
    background: hsl(var(--secondary));
    color: hsl(var(--foreground));
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ==========================================
   Layout
   ========================================== */

.app-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.main-content {
    flex: 1;
    padding: 2rem 1rem;
}

.content-wrapper {
    max-width: 1000px;
    margin: 0 auto;
}

/* ==========================================
   Header
   ========================================== */

.header {
    background: hsl(var(--card));
    border-bottom: 1px solid hsl(var(--border));
    padding: 1rem;
}

.header-content {
    max-width: 1000px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
}

.brand {
    display: flex;
    align-items: center;
    justify-content: center;
}

.brand-logo {
    height: 80px;
    width: auto;
    object-fit: contain;
}

/* ==========================================
   Hero Section
   ========================================== */

.hero-section {
    background: hsl(var(--card));
    border-bottom: 1px solid hsl(var(--border));
    padding: 1.5rem 1rem;
}

.hero-content {
    max-width: 700px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.hero-description {
    color: hsl(var(--muted-foreground));
    font-size: 0.9375rem;
    margin: 0;
    text-align: center;
    flex: 0 1 auto;
}

/* ==========================================
   Cards & Sections
   ========================================== */

.card {
    background: hsl(var(--card));
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

.section-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: hsl(var(--foreground));
    margin-bottom: 1.5rem;
    letter-spacing: -0.025em;
}

/* ==========================================
   Configuration Section
   ========================================== */

.config-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-label {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.label-text {
    font-size: 0.875rem;
    font-weight: 500;
    color: hsl(var(--foreground));
}

.label-hint {
    font-size: 0.8125rem;
    color: hsl(var(--muted-foreground));
    font-weight: 400;
}

/* Select Input */
.select-input {
    width: 100%;
    padding: 0.625rem 0.75rem;
    font-size: 0.875rem;
    border: 1px solid hsl(var(--input));
    border-radius: calc(var(--radius) - 2px);
    background: hsl(var(--background));
    color: hsl(var(--foreground));
    transition: all 0.2s ease;
    cursor: pointer;
}

.select-input:hover {
    border-color: hsl(var(--ring));
}

.select-input:focus {
    outline: none;
    border-color: hsl(var(--ring));
    box-shadow: 0 0 0 3px hsla(var(--ring), 0.1);
}

/* Checkbox */
.checkbox-label {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    cursor: pointer;
    padding: 0.5rem 0;
}

.checkbox-input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.checkbox-custom {
    display: block;
    width: 1.25rem;
    height: 1.25rem;
    min-width: 1.25rem;
    border: 2px solid hsl(var(--input));
    border-radius: 4px;
    background: hsl(var(--background));
    transition: all 0.2s ease;
    position: relative;
    margin-top: 0.125rem;
}

.checkbox-input:checked + .checkbox-custom {
    background: hsl(var(--primary));
    border-color: hsl(var(--primary));
}

.checkbox-input:checked + .checkbox-custom::after {
    content: '';
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%) rotate(45deg);
    width: 0.4rem;
    height: 0.7rem;
    border: solid hsl(var(--primary-foreground));
    border-width: 0 2px 2px 0;
}

.checkbox-custom:hover {
    border-color: hsl(var(--ring));
}

.checkbox-text {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
}

/* ==========================================
   Upload Section
   ========================================== */

.upload-section {
    padding: 2rem;
}

.upload-area {
    border: 2px dashed hsl(var(--border));
    border-radius: var(--radius);
    padding: 3rem 2rem;
    text-align: center;
    transition: all 0.2s ease;
    cursor: pointer;
    background: hsl(var(--background));
}

.upload-area:hover {
    border-color: hsl(var(--ring));
    background: hsl(var(--accent));
}

.upload-area.dragover {
    border-color: hsl(var(--ring));
    background: hsl(var(--accent));
    border-style: solid;
}

.upload-area.file-ready {
    border-color: hsl(var(--success));
    background: hsl(var(--background));
    border-style: solid;
}

.upload-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.upload-icon {
    color: hsl(var(--muted-foreground));
    margin-bottom: 0.5rem;
}

.file-success-icon {
    color: hsl(var(--success));
    margin-bottom: 0.5rem;
}

.upload-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: hsl(var(--foreground));
}

.upload-description {
    font-size: 0.9375rem;
    color: hsl(var(--muted-foreground));
}

.upload-formats {
    font-size: 0.8125rem;
    color: hsl(var(--muted-foreground));
    margin-bottom: 0.5rem;
}

.file-input {
    display: none;
}

.file-name {
    font-size: 1.125rem;
    font-weight: 600;
    color: hsl(var(--foreground));
    word-break: break-word;
}

.file-size {
    font-size: 0.875rem;
    color: hsl(var(--muted-foreground));
}

.file-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: hsl(var(--success));
    font-size: 0.875rem;
    font-weight: 500;
}

.status-dot {
    width: 8px;
    height: 8px;
    background: hsl(var(--success));
    border-radius: 50%;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.status-text {
    color: hsl(var(--success));
}

/* ==========================================
   Buttons
   ========================================== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    padding: 0.625rem 1rem;
    border-radius: calc(var(--radius) - 2px);
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.btn:focus-visible {
    outline: 2px solid hsl(var(--ring));
    outline-offset: 2px;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Button Variants */
.btn-primary {
    background: hsl(var(--primary));
    color: hsl(var(--primary-foreground));
}

.btn-primary:hover:not(:disabled) {
    background: hsl(var(--primary) / 0.9);
}

.btn-primary:active:not(:disabled) {
    background: hsl(var(--primary) / 0.95);
}

.btn-outline {
    background: transparent;
    border: 1px solid hsl(var(--input));
    color: hsl(var(--foreground));
}

.btn-outline:hover:not(:disabled) {
    background: hsl(var(--accent));
    border-color: hsl(var(--ring));
}

.btn-large {
    width: 100%;
    padding: 0.875rem 1.5rem;
    font-size: 1rem;
    margin-top: 1.5rem;
}

.btn-sm {
    padding: 0.5rem 0.875rem;
    font-size: 0.8125rem;
}

.button-group {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* ==========================================
   Loading State
   ========================================== */

.loading-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: hsla(var(--background), 0.8);
    backdrop-filter: blur(4px);
    z-index: 50;
    align-items: center;
    justify-content: center;
}

.loading-overlay.show {
    display: flex;
}

.loading-content {
    text-align: center;
    padding: 2rem;
}

.spinner {
    width: 3rem;
    height: 3rem;
    border: 3px solid hsl(var(--border));
    border-top-color: hsl(var(--foreground));
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

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

.loading-text {
    font-size: 1rem;
    font-weight: 500;
    color: hsl(var(--foreground));
    margin-bottom: 0.25rem;
}

.loading-subtext {
    font-size: 0.875rem;
    color: hsl(var(--muted-foreground));
}

/* ==========================================
   Alerts & Messages
   ========================================== */

.alert {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    border-radius: var(--radius);
    margin-bottom: 1.5rem;
    font-size: 0.875rem;
}

.alert-error {
    background: hsl(var(--error) / 0.1);
    border: 1px solid hsl(var(--error) / 0.3);
    color: hsl(var(--error));
}

.alert-icon {
    flex-shrink: 0;
}

.alert-message {
    flex: 1;
}

/* Toast Notification */
.toast {
    position: fixed;
    top: 1rem;
    right: 1rem;
    max-width: 400px;
    background: hsl(var(--card));
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius);
    padding: 1rem;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    z-index: 100;
    opacity: 0;
    transform: translateY(-1rem);
    transition: all 0.3s ease;
    pointer-events: none;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.toast-content {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.toast-icon {
    flex-shrink: 0;
    color: hsl(var(--foreground));
}

.toast-message {
    font-size: 0.875rem;
    color: hsl(var(--foreground));
}

/* ==========================================
   Results Section
   ========================================== */

.result-section {
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(1rem);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.result-card {
    padding: 2rem;
}

.result-header {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 1.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid hsl(var(--border));
}

.download-actions {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.download-label {
    font-size: 0.875rem;
    font-weight: 500;
    color: hsl(var(--muted-foreground));
}

.result-content {
    font-size: 0.9375rem;
    line-height: 1.7;
    color: hsl(var(--foreground));
    white-space: pre-wrap;
}

/* Speaker segments */
.result-content > div {
    margin-bottom: 1rem;
    padding: 1rem;
    background: hsl(var(--muted));
    border-radius: calc(var(--radius) - 2px);
    border-left: 3px solid hsl(var(--primary));
}

.result-content strong {
    color: hsl(var(--primary));
    font-weight: 600;
    display: block;
    margin-bottom: 0.25rem;
}

.result-content small {
    color: hsl(var(--muted-foreground));
    font-size: 0.8125rem;
}

/* ==========================================
   Footer
   ========================================== */

.footer {
    background: hsl(var(--card));
    border-top: 1px solid hsl(var(--border));
    padding: 1.5rem 1rem;
    margin-top: auto;
}

.footer-text {
    text-align: center;
    font-size: 0.8125rem;
    color: hsl(var(--muted-foreground));
    max-width: 1000px;
    margin: 0 auto;
}

/* ==========================================
   Responsive Design
   ========================================== */

@media (max-width: 768px) {
    .main-content {
        padding: 1rem 0.5rem;
    }

    .header {
        padding: 1.5rem 1rem;
    }

    .brand-logo {
        height: 52px;
    }

    .config-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .card {
        padding: 1rem;
    }

    .upload-section {
        padding: 1rem;
    }

    .upload-area {
        padding: 2rem 1rem;
    }

    .result-header {
        flex-direction: column;
    }

    .button-group {
        flex-direction: column;
    }

    .btn-sm {
        width: 100%;
    }

    .toast {
        left: 1rem;
        right: 1rem;
        max-width: none;
    }
}

@media (max-width: 480px) {
    .brand-logo {
        height: 48px;
    }

    .hero-content {
        flex-direction: column;
        gap: 0.75rem;
    }

    .hero-description {
        font-size: 0.875rem;
    }

    .language-toggle {
        width: 32px;
        height: 32px;
    }

    .section-title {
        font-size: 1rem;
    }

    .upload-title {
        font-size: 1rem;
    }

    [dir="rtl"] .hero-content {
        flex-direction: column;
    }
}

/* ==========================================
   Utilities
   ========================================== */

.show {
    display: block !important;
}

.hide {
    display: none !important;
}

/* ==========================================
   RTL Support for Arabic
   ========================================== */

[dir="rtl"] {
    text-align: right;
}

/* Header RTL */
[dir="rtl"] .header-content {
    justify-content: center;
}

[dir="rtl"] .brand {
    justify-content: center;
}

[dir="rtl"] .hero-content {
    flex-direction: row-reverse;
}

[dir="rtl"] .hero-description {
    text-align: center;
}

/* Language toggle button */
.language-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0.5rem;
    border: 1px solid hsl(var(--border));
    border-radius: calc(var(--radius) - 2px);
    background: hsl(var(--background));
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.language-toggle:hover {
    background: hsl(var(--accent));
    border-color: hsl(var(--ring));
}

.language-toggle:active {
    transform: scale(0.95);
}

.language-toggle img {
    display: block;
    width: 20px;
    height: 20px;
}


/* Buttons RTL */
[dir="rtl"] .btn {
    flex-direction: row-reverse;
}

[dir="rtl"] .button-group {
    flex-direction: row-reverse;
}

/* Form labels RTL */
[dir="rtl"] .form-label {
    text-align: right;
}

[dir="rtl"] .checkbox-label {
    flex-direction: row-reverse;
}

[dir="rtl"] .checkbox-custom {
    margin-right: 0;
    margin-left: 0.75rem;
}

/* Toast RTL */
[dir="rtl"] .toast {
    left: 1rem;
    right: auto;
}

[dir="rtl"] .toast-content {
    flex-direction: row-reverse;
}

/* Alert RTL */
[dir="rtl"] .alert {
    flex-direction: row-reverse;
}

/* Result header RTL */
[dir="rtl"] .result-header {
    text-align: right;
}

[dir="rtl"] .download-actions {
    align-items: flex-start;
}

/* Config grid RTL - ensure proper alignment */
[dir="rtl"] .config-grid {
    text-align: right;
}

/* Upload area RTL */
[dir="rtl"] .upload-area {
    text-align: right;
}

[dir="rtl"] .upload-state {
    text-align: center;
}

/* File status RTL */
[dir="rtl"] .file-status {
    flex-direction: row-reverse;
}

/* Result content RTL */
[dir="rtl"] .result-content {
    text-align: right;
}

[dir="rtl"] .result-content > div {
    border-left: none;
    border-right: 3px solid hsl(var(--primary));
}

/* Loading content RTL */
[dir="rtl"] .loading-content {
    text-align: center;
}

/* Select inputs RTL */
[dir="rtl"] .select-input {
    text-align: right;
    padding-right: 0.75rem;
}

/* Checkbox text RTL */
[dir="rtl"] .checkbox-text {
    text-align: right;
}

/* Timestamp styling for RTL */
[dir="rtl"] small {
    margin-left: 0;
    margin-right: 0.5rem;
}

/* ==========================================
   SVG Icon Images - Asset Support
   ========================================== */

/* Ensure SVG icons inherit color from parent */
.toast-icon,
.upload-icon,
.file-success-icon,
.alert-icon,
.btn img,
.download-btn img {
    display: inline-block;
    vertical-align: middle;
    flex-shrink: 0;
}

/* SVG color inheritance - for stroke-based icons */
img[src$=".svg"] {
    /* Allow SVGs to use currentColor from parent */
    color: inherit;
}

/* Specific icon color overrides */
.upload-icon,
.upload-area:hover .upload-icon {
    /* Inherits muted-foreground color from parent */
    opacity: 1;
}

.file-success-icon {
    /* Success green already set by parent color */
    opacity: 1;
}

/* Button icons */
.btn img {
    pointer-events: none; /* Prevents icon from blocking button clicks */
}

/* Toast and alert icons */
.toast-icon,
.alert-icon {
    flex-shrink: 0;
}
