@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&family=Tajawal:wght@300;400;500;700;800;900&display=swap');

:root {
    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --bg-card: #ffffff;
    --border-color: #e2e8f0;
    --border-hover: #cbd5e1;
    
    --color-primary: #3b82f6;
    --color-primary-light: #60a5fa;
    --color-primary-dark: #2563eb;
    --color-success: #10b981;
    --color-warning: #f59e0b;
    --color-danger: #ef4444;
    --color-info: #3b82f6;
    
    --text-main: #0f172a;
    --text-muted: #475569;
    --text-sub: #64748b;
    
    --font-en: 'Plus Jakarta Sans', sans-serif;
    --font-ar: 'Tajawal', sans-serif;
    
    --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-pill: 9999px;
    
    --shadow-main: 0 4px 12px -2px rgba(15, 23, 42, 0.04), 0 2px 4px -1px rgba(15, 23, 42, 0.04);
    --glow-primary: 0 0 10px rgba(59, 130, 246, 0.05);
}

body[data-theme="dark"] {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-card: #1e293b;
    --border-color: #334155;
    --border-hover: #475569;
    
    --text-main: #f8fafc;
    --text-muted: #cbd5e1;
    --text-sub: #94a3b8;
    
    --shadow-main: 0 4px 20px -2px rgba(0, 0, 0, 0.3), 0 2px 6px -1px rgba(0, 0, 0, 0.2);
    --glow-primary: 0 0 15px rgba(59, 130, 246, 0.15);
}

/* Base resets & Direction handling */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-primary);
    background-image: 
        radial-gradient(at 10% 10%, rgba(59, 130, 246, 0.03) 0px, transparent 50%),
        radial-gradient(at 90% 90%, rgba(16, 185, 129, 0.02) 0px, transparent 50%);
    background-attachment: fixed;
    color: var(--text-main);
    font-family: var(--font-en);
    font-size: 16px;
    line-height: 1.6;
    overflow-x: hidden;
    min-height: 100vh;
}

body[dir="rtl"] {
    font-family: var(--font-ar);
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: var(--bg-primary);
}
::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border: 2px solid var(--bg-primary);
    border-radius: var(--radius-pill);
}
::-webkit-scrollbar-thumb:hover {
    background: var(--border-hover);
}

/* Glassmorphism utility classes */
.glass-panel {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-main);
    transition: var(--transition-normal);
}

.glass-panel:hover {
    border-color: var(--border-hover);
}

/* Navigation layout */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 2rem;
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.05);
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo-icon {
    width: 2.25rem;
    height: 2.25rem;
    background: linear-gradient(135deg, var(--color-primary), var(--color-success));
    border-radius: 30% 70% 70% 30% / 30% 30% 70% 70%;
    animation: morph 8s ease-in-out infinite;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 800;
    font-size: 1.1rem;
}

@keyframes morph {
    0% { border-radius: 30% 70% 70% 30% / 30% 30% 70% 70%; }
    50% { border-radius: 70% 30% 30% 70% / 70% 70% 30% 30%; }
    100% { border-radius: 30% 70% 70% 30% / 30% 30% 70% 70%; }
}

.logo-text {
    font-weight: 800;
    font-size: 1.5rem;
    letter-spacing: -0.5px;
    color: var(--text-main);
}

body[dir="rtl"] .logo-text {
    letter-spacing: 0;
}

.nav-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* Button UI */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.45rem 0.9rem;
    font-family: inherit;
    font-weight: 600;
    font-size: 0.85rem;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition-fast);
    border: 1px solid transparent;
    color: var(--text-main);
    background: transparent;
}

.btn-primary {
    background: var(--color-primary);
    color: #ffffff;
    border-color: var(--color-primary);
}
.btn-primary:hover {
    background: var(--color-primary-dark);
    border-color: var(--color-primary-dark);
    color: #ffffff;
}
.btn-secondary {
    background: var(--bg-secondary);
    border-color: var(--border-color);
    color: var(--text-muted);
}
.btn-secondary:hover {
    background: var(--bg-primary);
    border-color: var(--border-hover);
    color: var(--text-main);
}
.btn-danger {
    background: rgba(239, 68, 68, 0.08);
    color: var(--color-danger);
    border-color: rgba(239, 68, 68, 0.15);
}
.btn-danger:hover {
    background: var(--color-danger);
    color: #ffffff;
    border-color: var(--color-danger);
}
.btn-success {
    background: rgba(16, 185, 129, 0.08);
    color: var(--color-success);
    border-color: rgba(16, 185, 129, 0.15);
}
.btn-success:hover {
    background: var(--color-success);
    color: #ffffff;
    border-color: var(--color-success);
}
.btn-tab {
    padding: 0.4rem 0.85rem;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 0.85rem;
}
.btn-tab.active {
    background: rgba(59, 130, 246, 0.08);
    color: var(--color-primary-dark);
    border: 1px solid rgba(59, 130, 246, 0.15);
}

/* Lang toggle button */
.lang-toggle {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-color);
    padding: 0.5rem 0.8rem;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--color-success);
    border-radius: var(--radius-md);
}

/* App Main Container */
.main-container {
    max-width: 1750px;
    margin: 1.5rem auto;
    padding: 0 1.5rem;
    width: 95%;
}

/* Views Grid */
.view-section {
    display: none;
    animation: fadeIn var(--transition-normal);
}
.view-section.active {
    display: block;
}

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

/* Dashboard View */
.dashboard-summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.summary-card {
    padding: 1.75rem;
    position: relative;
    overflow: hidden;
}

.summary-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: var(--color-primary);
}
body[dir="rtl"] .summary-card::before {
    left: auto;
    right: 0;
}

.summary-card.nps-card::before { background: var(--color-success); }
.summary-card.sentiment-card::before { background: var(--color-info); }
.summary-card.survey-count-card::before { background: var(--color-warning); }

.card-label {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.card-value {
    font-size: 2.25rem;
    font-weight: 800;
    line-height: 1.2;
}

.card-subtext {
    font-size: 0.8rem;
    color: var(--text-sub);
    margin-top: 0.5rem;
}

/* Survey List view grid */
.survey-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1.5rem;
}

.survey-card {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 200px;
    position: relative;
}

.survey-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1rem;
}

.survey-category {
    font-size: 0.75rem;
    padding: 0.2rem 0.6rem;
    background: rgba(139, 92, 246, 0.15);
    color: var(--color-primary-light);
    border-radius: var(--radius-pill);
    font-weight: 600;
}

.survey-lang-indicator {
    font-size: 0.75rem;
    color: var(--text-sub);
}

.survey-card-title {
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    line-height: 1.3;
}

.survey-card-desc {
    font-size: 0.85rem;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    margin-bottom: 1.5rem;
}

.survey-card-actions {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    border-top: 1px solid var(--border-color);
    padding-top: 1rem;
    margin-top: auto;
}

.card-action-row {
    display: flex;
    gap: 0.5rem;
    width: 100%;
}

.card-action-row.main-actions {
    flex-direction: column;
    gap: 0.5rem;
}

.card-action-row.sub-actions {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
}

.survey-card-actions .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.55rem 0.75rem;
    font-size: 0.8rem;
    font-weight: 500;
    width: 100%;
    margin: 0;
    box-sizing: border-box;
}

.btn-success-filled {
    background: var(--color-success);
    color: #ffffff;
    border: 1px solid var(--color-success);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition-fast);
}
.btn-success-filled:hover {
    background: #059669;
    border-color: #059669;
    color: #ffffff;
}

/* Builder Layout Split View */
.builder-layout {
    display: grid;
    grid-template-columns: 280px 1fr 340px;
    gap: 1.5rem;
    align-items: start;
    min-height: 800px;
}

.builder-header-sticky {
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 78px;
    z-index: 90;
    background: var(--bg-primary);
    padding: 1rem 0;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    box-shadow: 0 2px 4px rgba(0,0,0,0.02);
}

@media (max-width: 1200px) {
    .builder-layout {
        grid-template-columns: 250px 1fr;
    }
    .builder-layout .suggestions-panel {
        grid-column: span 2;
    }
}
@media (max-width: 768px) {
    .builder-layout {
        grid-template-columns: 1fr;
    }
    .builder-layout .suggestions-panel,
    .builder-layout .toolbox-panel {
        grid-column: span 1;
    }
}

.builder-panel {
    padding: 1.25rem;
    position: sticky;
    top: 160px;
}

/* Tool box list */
.toolbox-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: 1rem;
}

.toolbox-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.85rem 1rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    cursor: grab;
    transition: var(--transition-fast);
    font-weight: 500;
    font-size: 0.9rem;
}

.toolbox-item:hover {
    background: rgba(139, 92, 246, 0.08);
    border-color: var(--color-primary-light);
    transform: translateX(4px);
}
body[dir="rtl"] .toolbox-item:hover {
    transform: translateX(-4px);
}

.toolbox-item i {
    color: var(--color-primary-light);
}

/* Builder Main Canvas */
.canvas-container {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.canvas-meta-section {
    padding: 1.5rem;
}

.form-group {
    margin-bottom: 1.25rem;
}

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

label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.input-field {
    width: 100%;
    padding: 0.75rem 1rem;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-main);
    font-family: inherit;
    font-size: 0.95rem;
    transition: var(--transition-fast);
}

.input-field:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 10px rgba(139, 92, 246, 0.15);
}

.canvas-droptarget {
    border: 2.5px dashed var(--border-color);
    border-radius: var(--radius-lg);
    padding: 3rem 2rem;
    text-align: center;
    color: var(--text-sub);
    transition: var(--transition-fast);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    background: rgba(255, 255, 255, 0.01);
}

.canvas-droptarget.dragover {
    border-color: var(--color-primary);
    background: rgba(139, 92, 246, 0.05);
    color: var(--color-primary-light);
}

/* Added Question Cards in Canvas */
.question-card {
    padding: 1.5rem;
    position: relative;
    animation: slideUp var(--transition-normal);
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(15px); }
    to { opacity: 1; transform: translateY(0); }
}

.question-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
    cursor: move;
}

.question-badge {
    font-size: 0.75rem;
    padding: 0.15rem 0.5rem;
    background: rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-sm);
    font-weight: 700;
    color: var(--text-muted);
}

.question-card-controls {
    display: flex;
    gap: 0.5rem;
}

.question-card-body {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.question-translation-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

@media (max-width: 600px) {
    .question-translation-grid {
        grid-template-columns: 1fr;
    }
}

/* Question Option Builders */
.options-builder {
    margin-top: 0.5rem;
    background: rgba(0, 0, 0, 0.15);
    padding: 1rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.option-row {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    align-items: center;
}

.option-row:last-child {
    margin-bottom: 0;
}

/* Logic Builder panel CSS */
.logic-rule-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    padding: 1rem;
    border-radius: var(--radius-md);
    margin-bottom: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.logic-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
}

.logic-row select, .logic-row input {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 0.35rem 0.5rem;
    border-radius: var(--radius-sm);
    outline: none;
    font-size: 0.85rem;
}

/* Suggestions Sidebar panel */
.suggestions-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-height: 500px;
    overflow-y: auto;
    margin-top: 1rem;
    padding-right: 0.25rem;
}

body[dir="rtl"] .suggestions-list {
    padding-right: 0;
    padding-left: 0.25rem;
}

.suggestion-item {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    padding: 0.85rem;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition-fast);
    text-align: start;
}

.suggestion-item:hover {
    background: rgba(16, 185, 129, 0.05);
    border-color: rgba(16, 185, 129, 0.3);
}

.suggestion-item-title {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--color-success);
    margin-bottom: 0.25rem;
    display: flex;
    justify-content: space-between;
}

.suggestion-item-text {
    font-size: 0.85rem;
    line-height: 1.4;
    color: var(--text-main);
}

.suggestion-item-text-sub {
    font-size: 0.75rem;
    color: var(--text-sub);
    margin-top: 0.25rem;
}

/* Analytics & VoC Dashboard Layout */
.analytics-layout {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1.5rem;
    align-items: start;
}

@media (max-width: 1024px) {
    .analytics-layout {
        grid-template-columns: 1fr;
    }
}

.analytics-main-panel {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.chart-card {
    padding: 1.5rem;
}

.chart-card-title {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chart-container {
    position: relative;
    height: 300px;
    width: 100%;
}

/* Recommendations Insights side panel */
.insights-panel {
    padding: 1.5rem;
}

.insights-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-top: 1rem;
}

.insight-card {
    padding: 1rem;
    border-radius: var(--radius-md);
    position: relative;
    border: 1px solid transparent;
}

.insight-card.insight-success {
    background: rgba(16, 185, 129, 0.08);
    border-color: rgba(16, 185, 129, 0.2);
    color: var(--text-main);
}
.insight-card.insight-warning {
    background: rgba(245, 158, 11, 0.08);
    border-color: rgba(245, 158, 11, 0.2);
}
.insight-card.insight-critical {
    background: rgba(239, 108, 108, 0.08);
    border-color: rgba(239, 108, 108, 0.2);
}
.insight-card.insight-info {
    background: rgba(59, 130, 246, 0.08);
    border-color: rgba(59, 130, 246, 0.2);
}

.insight-icon {
    font-weight: 800;
    font-size: 0.8rem;
    text-transform: uppercase;
    margin-bottom: 0.25rem;
}
.insight-card.insight-success .insight-icon { color: var(--color-success); }
.insight-card.insight-warning .insight-icon { color: var(--color-warning); }
.insight-card.insight-critical .insight-icon { color: var(--color-danger); }
.insight-card.insight-info .insight-icon { color: var(--color-info); }

.insight-title {
    font-weight: 700;
    font-size: 0.95rem;
    margin-bottom: 0.35rem;
}

.insight-desc {
    font-size: 0.8rem;
    color: var(--text-muted);
    line-height: 1.4;
}

/* Feedback/Text response logs */
.feedback-log-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-height: 350px;
    overflow-y: auto;
    padding-right: 0.25rem;
}

.feedback-log-item {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    padding: 1rem;
    border-radius: var(--radius-md);
    font-size: 0.9rem;
}

.feedback-log-header {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--text-sub);
    margin-bottom: 0.5rem;
}

.feedback-sentiment-badge {
    padding: 0.1rem 0.5rem;
    border-radius: var(--radius-sm);
    font-weight: 700;
    text-transform: uppercase;
}

.feedback-sentiment-badge.positive {
    background: rgba(16, 185, 129, 0.15);
    color: var(--color-success);
}
.feedback-sentiment-badge.neutral {
    background: rgba(156, 163, 175, 0.15);
    color: var(--text-muted);
}
.feedback-sentiment-badge.negative {
    background: rgba(239, 68, 68, 0.15);
    color: var(--color-danger);
}

/* Survey Run (Respondent Page) Styles */
.run-page-container {
    max-width: 680px;
    margin: 4rem auto;
    padding: 0 1.25rem;
}

.run-progress-container {
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: var(--radius-pill);
    margin-bottom: 2rem;
    overflow: hidden;
}

.run-progress-bar {
    height: 100%;
    width: 0;
    background: linear-gradient(to right, var(--color-primary), var(--color-success));
    border-radius: var(--radius-pill);
    transition: width var(--transition-normal);
}

.run-card {
    padding: 2.5rem;
}

.run-survey-title {
    font-size: 1.75rem;
    font-weight: 800;
    margin-bottom: 0.75rem;
    text-align: center;
}

.run-survey-desc {
    color: var(--text-muted);
    font-size: 0.95rem;
    text-align: center;
    margin-bottom: 2.5rem;
}

.run-question-wrapper {
    margin-bottom: 2.5rem;
}

.run-question-text {
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 1.25rem;
}

.run-question-text span.required-star {
    color: var(--color-danger);
    margin-inline-start: 0.25rem;
}

/* Answer Inputs in Taker View */
.run-options-list {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.run-option-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition-fast);
}

.run-option-item:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.2);
}

.run-option-item input[type="radio"],
.run-option-item input[type="checkbox"] {
    width: 1.2rem;
    height: 1.2rem;
    accent-color: var(--color-primary);
    cursor: pointer;
}

.run-option-item.selected {
    background: rgba(139, 92, 246, 0.08);
    border-color: var(--color-primary);
}

/* NPS Selector Grid */
.nps-selector-container {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.nps-grid {
    display: grid;
    grid-template-columns: repeat(11, 1fr);
    gap: 0.35rem;
}

.nps-btn {
    height: 3rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    cursor: pointer;
    font-weight: 700;
    font-size: 1.05rem;
    transition: var(--transition-fast);
}

.nps-btn:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: var(--text-muted);
}

.nps-btn.selected {
    background: var(--color-primary);
    border-color: var(--color-primary-light);
    color: white;
    box-shadow: var(--glow-primary);
}

.nps-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--text-sub);
    font-weight: 600;
}

/* Rating stars/circles selector */
.rating-selector {
    display: flex;
    gap: 0.75rem;
}

.rating-star {
    font-size: 2.25rem;
    color: var(--border-hover);
    cursor: pointer;
    transition: var(--transition-fast);
}

.rating-star:hover,
.rating-star.selected {
    color: var(--color-warning);
    text-shadow: 0 0 10px rgba(245, 158, 11, 0.3);
}

/* Actions footer */
.run-actions-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 2rem;
}

body[dir="rtl"] .run-actions-footer {
    flex-direction: row-reverse;
}

/* Modal UI */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(8px);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
}

.modal-overlay.active {
    display: flex;
}

.modal-card {
    width: 100%;
    max-width: 500px;
    padding: 2rem;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.modal-body {
    margin-bottom: 1.5rem;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
}

/* Drag drop visual handles */
.drag-handle {
    cursor: grab;
    color: var(--text-sub);
}
.drag-handle:active {
    cursor: grabbing;
}

/* ==========================================
   LOGIN SCREEN STYLES
   ========================================== */
.login-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: var(--bg-primary);
    display: flex;
    justify-content: center;
    align-items: flex-start;
    overflow-y: auto;
    z-index: 9999;
    padding: 2rem 1.5rem;
}

.landing-container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2.5rem;
}

.landing-header {
    text-align: center;
    margin-top: 1rem;
}

.landing-logo-img {
    height: 80px;
    width: auto;
    object-fit: contain;
    margin-bottom: 1rem;
    border-radius: var(--radius-md);
}

.landing-title {
    font-size: 2.25rem;
    font-weight: 800;
    color: var(--text-main);
    margin-bottom: 0.5rem;
}

.landing-subtitle {
    font-size: 1.1rem;
    color: var(--text-muted);
    max-width: 600px;
    margin: 0 auto;
}

.landing-content-grid {
    display: grid;
    grid-template-columns: 1.5fr 1fr;
    gap: 3rem;
    width: 100%;
    align-items: start;
}

@media (max-width: 968px) {
    .landing-content-grid {
        grid-template-columns: 1fr;
        gap: 2rem;
    }
}

/* Pricing Grid */
.plans-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.5rem;
    width: 100%;
}

.plan-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 2rem 1.5rem;
    text-align: center;
    transition: var(--transition-normal);
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 420px;
}

.plan-card.featured {
    border-color: var(--color-primary);
    box-shadow: 0 10px 30px rgba(59, 130, 246, 0.1);
}

.plan-badge {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: rgba(59, 130, 246, 0.1);
    color: var(--color-primary-dark);
    padding: 0.25rem 0.75rem;
    border-radius: var(--radius-pill);
    font-size: 0.75rem;
    font-weight: 700;
}

.plan-card:hover {
    transform: translateY(-4px);
    border-color: var(--color-primary-light);
}

.plan-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 0.5rem;
}

.plan-price {
    font-size: 2rem;
    font-weight: 800;
    color: var(--color-primary-dark);
    margin: 1rem 0;
}

.plan-price span {
    font-size: 0.9rem;
    color: var(--text-muted);
    font-weight: 500;
}

.plan-features {
    list-style: none;
    padding: 0;
    margin: 1.5rem 0;
    text-align: right;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.plan-features li {
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.plan-features li i {
    color: var(--color-success);
}

/* Auth Section */
.login-card {
    width: 100%;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 2.5rem 2rem;
    box-shadow: var(--shadow-main);
}

.auth-tabs {
    display: flex;
    border-bottom: 2px solid var(--border-color);
    margin-bottom: 2rem;
}

.auth-tab-btn {
    flex: 1;
    background: none;
    border: none;
    padding: 0.75rem;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    text-align: center;
    transition: var(--transition-fast);
}

.auth-tab-btn.active {
    color: var(--color-primary);
    border-bottom: 2px solid var(--color-primary);
    margin-bottom: -2px;
}

/* Social Buttons */
.social-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-top: 1.5rem;
    border-top: 1px solid var(--border-color);
    padding-top: 1.5rem;
}

.btn-social {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 0.6rem 1rem;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    transition: var(--transition-fast);
}

.btn-social:hover {
    background: var(--border-color);
    border-color: var(--border-hover);
}

.btn-google i {
    color: #ea4335;
}

.btn-apple i {
    color: #000000;
}

/* Verification State View */
.verification-card {
    text-align: center;
    padding: 3rem 2rem;
}

.verification-card i {
    font-size: 4rem;
    color: var(--color-primary);
    margin-bottom: 1.5rem;
}

.verification-card h2 {
    font-size: 1.5rem;
    margin-bottom: 1rem;
}

.verification-card p {
    color: var(--text-muted);
    margin-bottom: 2rem;
}

/* White Theme Adjustments for Existing CSS elements */
.error-alert {
    background: #fef2f2;
    border: 1px solid #fee2e2;
    color: #ef4444;
}

.users-table th {
    border-bottom: 1px solid var(--border-color);
    color: var(--text-main);
    font-weight: 600;
    font-size: 0.85rem;
}

.users-table td {
    border-bottom: 1px solid var(--border-color);
    font-size: 0.9rem;
    color: var(--text-main);
}

.users-table tr:hover td {
    background: var(--bg-primary);
}

.role-badge {
    display: inline-block;
    padding: 0.25rem 0.6rem;
    border-radius: var(--radius-pill);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.role-badge.superadmin {
    background: rgba(59, 130, 246, 0.1);
    color: var(--color-primary-dark);
    border: 1px solid rgba(59, 130, 246, 0.2);
}

.role-badge.admin {
    background: rgba(16, 185, 129, 0.1);
    color: #047857;
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.btn-logout {
    background: rgba(239, 68, 68, 0.05);
    color: var(--color-danger);
    border: 1px solid rgba(239, 68, 68, 0.15);
}

.btn-logout:hover {
    background: var(--color-danger);
    color: white;
    border-color: var(--color-danger);
}

/* User Management Dashboard Grid & Styling */
.users-grid {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 1.5rem;
    margin-top: 1.5rem;
    align-items: start;
}

@media (max-width: 992px) {
    .users-grid {
        grid-template-columns: 1fr;
    }
}

.user-form-card, .users-list-card {
    padding: 2rem !important;
}

.users-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin-top: 0.5rem;
}

.users-table th {
    background-color: var(--bg-primary);
    border-bottom: 2px solid var(--border-color);
    padding: 0.75rem 1rem;
    font-weight: 700;
    color: var(--text-main);
    font-size: 0.85rem;
    text-align: start;
}

body[dir="rtl"] .users-table th {
    text-align: right;
}

.users-table td {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-main);
    font-size: 0.9rem;
    vertical-align: middle;
    text-align: start;
}

body[dir="rtl"] .users-table td {
    text-align: right;
}

.users-table tr:last-child td {
    border-bottom: none;
}

.users-table tr:hover td {
    background-color: var(--bg-primary);
}

.metric-mini-card {
    background-color: var(--bg-primary) !important;
    border: 1px solid var(--border-color) !important;
    padding: 1.25rem !important;
    border-radius: var(--radius-md) !important;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.02) !important;
    transition: var(--transition-fast);
}

.metric-mini-card:hover {
    border-color: var(--color-primary-light) !important;
    transform: translateY(-2px);
}

/* Dark mode specific elements overrides */
body[data-theme="dark"] .btn-tab.active {
    background: rgba(59, 130, 246, 0.2);
    color: var(--color-primary-light);
    border: 1px solid rgba(59, 130, 246, 0.3);
}

body[data-theme="dark"] .btn-apple i {
    color: #ffffff;
}

/* Transaction Status Badges & Accounting Card customisations */
.status-badge {
    display: inline-block;
    padding: 0.25rem 0.6rem;
    border-radius: var(--radius-pill);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}
.status-badge.success {
    background: rgba(16, 185, 129, 0.1);
    color: var(--color-success);
    border: 1px solid rgba(16, 185, 129, 0.2);
}
.status-badge.pending {
    background: rgba(245, 158, 11, 0.1);
    color: var(--color-warning);
    border: 1px solid rgba(245, 158, 11, 0.2);
}
.status-badge.failed {
    background: rgba(239, 68, 68, 0.1);
    color: var(--color-danger);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

/* ==========================================
   MOBILE & TABLET RESPONSIVENESS OVERRIDES
   ========================================== */
@media (max-width: 768px) {
    /* Header & Navigation */
    header {
        padding: 0.75rem 1rem;
        flex-direction: column;
        gap: 0.75rem;
        align-items: stretch;
        text-align: center;
    }
    
    .logo-container {
        justify-content: center;
    }
    
    .nav-controls {
        justify-content: space-between;
        width: 100%;
        gap: 0.5rem;
    }

    /* Main Container */
    .main-container {
        margin: 1rem auto;
        padding: 0 1rem;
    }

    /* Dashboard Summary Grid */
    .dashboard-summary-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    /* Survey Cards & Actions */
    .survey-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .survey-card {
        padding: 1.25rem;
        min-height: auto;
    }

    .survey-card-actions {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .survey-card-actions .btn {
        padding: 0.4rem 0.6rem;
        font-size: 0.75rem;
    }

    /* Survey Run ( Taker View ) */
    .run-page-container {
        margin: 1.5rem auto;
        padding: 0 0.75rem;
    }

    .run-card {
        padding: 1.5rem 1.25rem;
    }

    .run-survey-title {
        font-size: 1.35rem;
        margin-bottom: 0.5rem;
    }

    .run-survey-desc {
        font-size: 0.85rem;
        margin-bottom: 1.75rem;
    }

    .run-question-text {
        font-size: 1.05rem;
        margin-bottom: 1rem;
    }

    .run-option-item {
        padding: 0.75rem 1rem;
        font-size: 0.85rem;
    }

    /* NPS Selector Grid mobile view override */
    .nps-grid {
        display: flex;
        flex-wrap: nowrap;
        overflow-x: auto;
        padding-bottom: 0.5rem;
        gap: 0.4rem;
        -webkit-overflow-scrolling: touch;
        justify-content: flex-start;
    }
    
    .nps-btn {
        flex: 0 0 2.2rem;
        height: 2.2rem;
        width: 2.2rem;
        min-width: 2.2rem;
        font-size: 0.85rem;
    }

    /* Rating Stars Sizing */
    .rating-star {
        font-size: 1.75rem;
    }

    /* Form Fields */
    .input-field {
        padding: 0.6rem 0.85rem;
        font-size: 0.85rem;
    }
}

@media (max-width: 480px) {
    /* Extra narrow mobile styling adjustments */
    .run-actions-footer {
        flex-direction: column-reverse;
        gap: 0.75rem;
        align-items: stretch;
    }
    
    .run-actions-footer .btn {
        width: 100%;
        padding: 0.6rem 1rem;
    }
    
    /* Login & Landing Page on very small viewports */
    .login-overlay {
        padding: 1rem 0.75rem;
    }
    
    .login-card {
        padding: 1.5rem 1rem;
    }
    
    .social-buttons {
        grid-template-columns: 1fr;
    }
}

/* App Splash Screen */
#appSplash {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #0f172a;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 99999;
}

body[data-theme="light"] #appSplash {
    background: #f8fafc;
}

.splash-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(59, 130, 246, 0.15);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 1s infinite linear;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}


