/**
 * Ledech Kiosk - Main Styles
 * Base styles, variables, and common components
 */

/* ========== CSS Variables ========== */
:root {
    /* Colors - Primary */
    --primary-color: #FF6B35;
    --primary-dark: #E55A2B;
    --primary-light: #FF8F66;
    --primary-glow: rgba(255, 107, 53, 0.4);

    /* Colors - Secondary */
    --secondary-color: #2D3436;
    --secondary-light: #636E72;

    /* Colors - Accent */
    --accent-gold: #F4C430;
    --accent-green: #00B894;
    --accent-red: #E74C3C;
    --accent-blue: #0984E3;

    /* Colors - Background */
    --bg-dark: #1A1A2E;
    --bg-darker: #0F0F1A;
    --bg-card: rgba(255, 255, 255, 0.95);
    --bg-card-dark: rgba(30, 30, 50, 0.95);
    --bg-overlay: rgba(0, 0, 0, 0.7);

    /* Colors - Text */
    --text-primary: #FFFFFF;
    --text-secondary: rgba(255, 255, 255, 0.7);
    --text-dark: #2D3436;
    --text-muted: #636E72;

    /* Colors - Status */
    --success-color: #00B894;
    --error-color: #E74C3C;
    --warning-color: #FDCB6E;
    --info-color: #74B9FF;

    /* Typography */
    --font-primary: 'Poppins', sans-serif;
    --font-arabic: 'Noto Sans Arabic', sans-serif;

    /* Font Sizes */
    --font-xs: 12px;
    --font-sm: 14px;
    --font-md: 16px;
    --font-lg: 18px;
    --font-xl: 24px;
    --font-2xl: 32px;
    --font-3xl: 48px;
    --font-4xl: 64px;

    /* Spacing */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
    --space-2xl: 48px;
    --space-3xl: 64px;

    /* Border Radius */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --radius-xl: 32px;
    --radius-full: 9999px;

    /* Shadows */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.15);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.2);
    --shadow-glow: 0 0 40px var(--primary-glow);

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-normal: 300ms ease;
    --transition-slow: 500ms ease;

    /* Z-Index */
    --z-base: 1;
    --z-dropdown: 100;
    --z-sticky: 200;
    --z-modal: 300;
    --z-overlay: 400;
    --z-toast: 500;
}

/* RTL Support */
[dir="rtl"] {
    --font-primary: 'Noto Sans Arabic', 'Poppins', sans-serif;
}

[dir="rtl"] .flip-rtl {
    transform: scaleX(-1);
}

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

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


/* ========== Reset ========== */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-primary);
    background-color: var(--bg-dark);
    color: var(--text-primary);
    overflow: hidden;
    width: 100vw;
    height: 100vh;
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
}

/* Prevent text selection and context menu */
body * {
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

/* Disable pull-to-refresh */
html,
body {
    overscroll-behavior: none;
}

/* ========== App Container ========== */
#app {
    width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden;
}

/* ========== Screens ========== */
.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--transition-fast);
    pointer-events: none;
}

.screen.active {
    opacity: 1 !important;
    visibility: visible !important;
    z-index: 100 !important;
    pointer-events: auto;
}

/* ========== Typography ========== */
h1,
h2,
h3,
h4,
h5,
h6 {
    font-weight: 700;
    line-height: 1.2;
}

h1 {
    font-size: var(--font-4xl);
}

h2 {
    font-size: var(--font-3xl);
}

h3 {
    font-size: var(--font-2xl);
}

h4 {
    font-size: var(--font-xl);
}

h5 {
    font-size: var(--font-lg);
}

h6 {
    font-size: var(--font-md);
}

p {
    line-height: 1.6;
}

/* ========== Buttons ========== */
button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    outline: none;
    background: none;
    -webkit-tap-highlight-color: transparent;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: var(--space-md) var(--space-xl);
    font-size: var(--font-lg);
    font-weight: 600;
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
    min-height: 56px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
    box-shadow: var(--shadow-md);
}

.btn-primary:hover,
.btn-primary:active {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg), var(--shadow-glow);
}

.btn-secondary {
    background: var(--bg-card);
    color: var(--text-dark);
    box-shadow: var(--shadow-sm);
}

.btn-secondary:hover,
.btn-secondary:active {
    background: #F5F5F5;
    transform: translateY(-2px);
}

.btn-outline {
    background: transparent;
    border: 2px solid var(--primary-color);
    color: var(--primary-color);
}

.btn-outline:hover,
.btn-outline:active {
    background: var(--primary-color);
    color: white;
}

.btn-ghost {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

.btn-ghost:hover,
.btn-ghost:active {
    background: rgba(255, 255, 255, 0.2);
}

.btn-lg {
    padding: var(--space-lg) var(--space-2xl);
    font-size: var(--font-xl);
    min-height: 72px;
    border-radius: var(--radius-lg);
}

.btn-sm {
    padding: var(--space-sm) var(--space-md);
    font-size: var(--font-sm);
    min-height: 40px;
}

.btn-icon {
    width: 56px;
    height: 56px;
    padding: 0;
    border-radius: var(--radius-full);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

/* ========== Cards ========== */
.card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    overflow: hidden;
}

.card-dark {
    background: var(--bg-card-dark);
    color: var(--text-primary);
}

/* ========== Inputs ========== */
input,
textarea {
    font-family: inherit;
    font-size: var(--font-lg);
    padding: var(--space-md) var(--space-lg);
    border: 2px solid rgba(0, 0, 0, 0.1);
    border-radius: var(--radius-md);
    background: white;
    color: var(--text-dark);
    width: 100%;
    transition: border-color var(--transition-fast);
}

input:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary-color);
}

input::placeholder,
textarea::placeholder {
    color: var(--text-muted);
}

/* ========== Overlays & Modals ========== */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-overlay);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: var(--z-overlay);
    backdrop-filter: blur(8px);
}

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-overlay);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: var(--z-modal);
    backdrop-filter: blur(8px);
}

.modal-content {
    background: var(--bg-card);
    border-radius: var(--radius-xl);
    padding: var(--space-2xl);
    max-width: 500px;
    width: 90%;
    text-align: center;
    color: var(--text-dark);
}

.modal-content .error-icon {
    font-size: 64px;
    color: var(--error-color);
    margin-bottom: var(--space-md);
}

.modal-content h2 {
    margin-bottom: var(--space-md);
    font-size: var(--font-2xl);
}

.modal-content p {
    margin-bottom: var(--space-xl);
    color: var(--text-muted);
}

/* ========== Legal Text Modal (KVKK vb. uzun, kaydırılabilir metinler) ==========
   Küçük .modal/.modal-content'ten farklı: sabit ekran, kaydırılabilir gövde,
   üstte kapat butonlu başlık + altta "Kapat" butonu. bkz. components/legalTextModal.js */
.legal-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-overlay, rgba(15, 23, 42, 0.55));
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 500;
    backdrop-filter: blur(6px);
    padding: 2rem;
    box-sizing: border-box;
}

.legal-modal-content {
    background: #ffffff;
    border-radius: 1.5rem;
    width: 100%;
    max-width: 720px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.legal-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid #e2e8f0;
    flex-shrink: 0;
}

.legal-modal-header h2 {
    font-size: 1.15rem;
    font-weight: 700;
    color: #1f2937;
    margin: 0;
}

.legal-modal-close-btn {
    border: none;
    background: #f1f5f9;
    color: #475569;
    border-radius: 999px;
    width: 2.5rem;
    height: 2.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
}

.legal-modal-body {
    padding: 1.25rem 1.5rem;
    overflow-y: auto;
    color: #334155;
    font-size: 0.95rem;
    line-height: 1.6;
}

.legal-modal-body h3 {
    font-size: 1rem;
    font-weight: 700;
    color: #1f2937;
    margin: 1.25rem 0 0.5rem;
}

.legal-modal-body h3:first-child {
    margin-top: 0;
}

.legal-modal-body p {
    margin: 0 0 0.75rem;
}

.legal-modal-body ul {
    margin: 0 0 0.75rem;
    padding-left: 1.25rem;
}

.legal-modal-body li {
    margin-bottom: 0.35rem;
}

.legal-modal-body table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 0.75rem;
    font-size: 0.85rem;
}

.legal-modal-body table td {
    border: 1px solid #e2e8f0;
    padding: 0.4rem 0.6rem;
}

.legal-draft-warning {
    background: rgba(245, 158, 11, 0.12);
    border: 1px solid rgba(245, 158, 11, 0.4);
    color: #92400e;
    padding: 0.6rem 0.85rem;
    border-radius: 0.75rem;
    font-size: 0.85rem;
    font-weight: 600;
}

.legal-modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid #e2e8f0;
    flex-shrink: 0;
    display: flex;
    justify-content: flex-end;
}

.legal-modal-footer .btn {
    min-width: 120px;
}

/* ========== Loading Spinner ========== */
.loading-spinner {
    text-align: center;
}

.spinner {
    width: 64px;
    height: 64px;
    border: 4px solid rgba(255, 255, 255, 0.2);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto var(--space-lg);
}

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

/* ========== Scrollbar ========== */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
    border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.3);
    border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.5);
}

/* ========== Utility Classes ========== */
.hidden {
    display: none !important;
}

.invisible {
    visibility: hidden !important;
}

.flex {
    display: flex;
}

.flex-col {
    flex-direction: column;
}

.items-center {
    align-items: center;
}

.justify-center {
    justify-content: center;
}

.justify-between {
    justify-content: space-between;
}

.gap-sm {
    gap: var(--space-sm);
}

.gap-md {
    gap: var(--space-md);
}

.gap-lg {
    gap: var(--space-lg);
}

.text-center {
    text-align: center;
}

.text-left {
    text-align: left;
}

.text-right {
    text-align: right;
}

.w-full {
    width: 100%;
}

.h-full {
    height: 100%;
}

/* ========== Material Icons ========== */
.material-icons-round {
    font-family: 'Material Icons Round';
    font-weight: normal;
    font-style: normal;
    font-size: 24px;
    display: inline-block;
    line-height: 1;
    text-transform: none;
    letter-spacing: normal;
    word-wrap: normal;
    white-space: nowrap;
    direction: ltr;
    -webkit-font-smoothing: antialiased;
    display: inline-block;
}

.material-symbols-outlined {
    font-family: 'Material Symbols Outlined';
    font-weight: normal;
    font-style: normal;
    font-size: 24px;
    display: inline-block;
    line-height: 1;
    text-transform: none;
    letter-spacing: normal;
    word-wrap: normal;
    white-space: nowrap;
    direction: ltr;
    -webkit-font-smoothing: antialiased;
}

/* ========== Badge ========== */
.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-xs) var(--space-sm);
    font-size: var(--font-xs);
    font-weight: 600;
    border-radius: var(--radius-full);
    min-width: 24px;
}

.badge-primary {
    background: var(--primary-color);
    color: white;
}

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

.badge-warning {
    background: var(--warning-color);
    color: var(--text-dark);
}

.badge-error {
    background: var(--error-color);
    color: white;
}

/* ========== Price Tag ========== */
.price {
    font-weight: 700;
    color: var(--primary-color);
}

.price-lg {
    font-size: var(--font-2xl);
}

.price-currency {
    font-size: 0.7em;
    margin-left: 2px;
}

/* ========== Status Indicators ========== */
.status-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    display: inline-block;
}

.status-open {
    background: var(--success-color);
    box-shadow: 0 0 8px var(--success-color);
}

.status-closed {
    background: var(--error-color);
}

/* ========== Responsive - For different kiosk screen sizes ========== */
@media screen and (max-width: 1280px) {
    :root {
        --font-4xl: 48px;
        --font-3xl: 36px;
        --font-2xl: 28px;
    }
}

@media screen and (min-width: 1920px) {
    :root {
        --font-4xl: 80px;
        --font-3xl: 56px;
        --font-2xl: 40px;
        --font-xl: 28px;
    }
}

/* ========== Language Change Animation ========== */
[data-i18n],
[data-i18n-placeholder] {
    transition: opacity 200ms ease;
}

.lang-changing [data-i18n],
.lang-changing [data-i18n-placeholder],
.lang-changing #lang-text-display {
    opacity: 0;
}

/* ========== RTL Overrides ========== */
/* Elements that should NOT flip in RTL mode */

/* Language selector - always stays on right */
#language-container {
    direction: ltr !important;
}

/* Language selector button content - always LTR layout */
#language-selector-btn {
    direction: ltr !important;
    flex-direction: row !important;
}

/* Dropdown - always LTR layout */
#language-dropdown {
    direction: ltr !important;
    right: 0 !important;
    left: auto !important;
}

/* Dropdown items - always left-aligned */
#language-dropdown .lang-btn {
    direction: ltr !important;
    text-align: left !important;
    flex-direction: row !important;
}

/* Footer payment logos container - prevent logo reordering in RTL */
[dir="rtl"] footer .flex.items-center.gap-6 {
    direction: ltr;
}

/* CTA button and rotating text - always LTR */
#start-order-btn {
    direction: ltr !important;
}

/* Rotating SVG text - always LTR */
#start-order-btn svg {
    direction: ltr !important;
}

/* App Logo - always LTR and left-aligned */
#app-logo {
    direction: ltr !important;
    left: 2rem !important;
    right: auto !important;
}

/* ========== Order Type Screen - Layout Stability ========== */

/* Title wrapper - fixed min-height to prevent jumping on language change */
.order-type-title-wrapper {
    min-height: 160px;
    display: flex;
    align-items: center;
    justify-content: center;
}

@media screen and (min-width: 1024px) {
    .order-type-title-wrapper {
        min-height: 200px;
    }
}

/* Fixed width navigation buttons */
.order-type-nav-btn {
    width: 180px;
    height: 56px;
    flex-shrink: 0;
    cursor: pointer;
}

/* Language selector wrapper */
.order-type-lang-wrapper {
    direction: ltr !important;
    width: 180px;
    flex-shrink: 0;
}

/* Bottom navigation bar */
.order-type-bottom-bar {
    direction: ltr !important;
}

/* Order type cards container */
.order-type-cards {
    direction: ltr !important;
}

/* Order type card cursor */
.order-type-card {
    cursor: pointer;
}

/* Order type lang item cursor */
.order-type-lang-item {
    cursor: pointer;
}

/* ========== RTL Fixes for Order Type Screen ========== */

[dir="rtl"] #order-type-screen h2 {
    direction: rtl;
}

[dir="rtl"] .order-type-cards {
    direction: ltr !important;
}

[dir="rtl"] .order-type-cards .text-center {
    direction: rtl;
}

[dir="rtl"] .order-type-bottom-bar {
    direction: ltr !important;
    flex-direction: row !important;
}

/* Smooth Swap Animation */
#order-type-back-btn,
#order-type-lang-container {
    transition: transform 0.6s cubic-bezier(0.2, 0, 0.2, 1);
}

[dir="rtl"] #order-type-back-btn {
    transform: translateX(204px);
}

/* Maintain icon flip inside the moved button */
[dir="rtl"] #order-type-back-btn .flip-rtl {
    transform: scaleX(-1);
}

[dir="rtl"] #order-type-lang-container {
    transform: translateX(-204px);
}

/* Active States (Press Effect) */
#order-type-back-btn:active,
#order-type-lang-btn:active {
    transform: scale(0.96);
}

/* RTL Back Button Active Override - Maintain Translation */
[dir="rtl"] #order-type-back-btn:active {
    transform: translateX(204px) scale(0.96);
}

/* Fix Internal Layout for Buttons in RTL (Icons should be on Right) */
[dir="rtl"] #order-type-back-btn,
[dir="rtl"] #order-type-lang-btn {
    direction: rtl;
}

[dir="rtl"] #order-type-lang-container {
    direction: ltr !important;
    /* Container stays LTR for positioning, inner button becomes RTL */
}

[dir="rtl"] #order-type-lang-btn {
    flex-direction: row !important;
}

[dir="rtl"] #order-type-lang-dropdown {
    direction: ltr !important;
}

[dir="rtl"] .order-type-lang-item {
    direction: ltr !important;
    text-align: left !important;
    flex-direction: row !important;
}

/* ========== Footer Language Dropdown (Shared Component) ========== */
.footer-lang-dropdown {
    z-index: 9999 !important;
    bottom: 95px !important;
    background: rgba(30, 30, 30, 0.6) !important;
    backdrop-filter: blur(30px) !important;
    -webkit-backdrop-filter: blur(30px) !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    border-radius: 2.5rem !important;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5) !important;
}

/* ========== Cart Badge RTL Support ========== */
.cart-badge {
    position: absolute;
    top: -6px;
    right: -6px;
    width: 28px;
    height: 28px;
    min-width: 28px;
    min-height: 28px;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #ef4444;
    /* red-500 */
    color: white;
    font-size: 0.75rem;
    /* text-xs */
    font-weight: 900;
    /* font-black */
    border-radius: 9999px;
    /* rounded-full */
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    /* shadow-lg */
    border: 2px solid white;
}

[dir="rtl"] .cart-badge {
    right: auto;
    left: -6px;
}