/**
 * Main Stylesheet
 * Modern responsive design with Tailwind-inspired utilities
 */

:root {
    --primary-color: #1e40af;
    --primary-dark: #1e3a8a;
    --secondary-color: #0891b2;
    --success-color: #059669;
    --error-color: #dc2626;
    --warning-color: #d97706;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    color: var(--gray-800);
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    background: white;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

.header {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
    padding: 30px;
    text-align: center;
}

.header h1 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 5px;
}

.header p {
    font-size: 1.1rem;
    opacity: 0.95;
}

.main-content {
    padding: 40px;
}

/* Progress Bar */
.progress-bar-container {
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--gray-200);
}

.progress-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.progress-track {
    height: 8px;
    background: var(--gray-200);
    border-radius: 4px;
    overflow: hidden;
    position: relative;
    margin-bottom: 16px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
    transition: width 0.3s ease;
    border-radius: 4px;
}

.step-indicators {
    display: flex;
    justify-content: space-between;
    gap: 8px;
}

.step-indicator {
    flex: 1;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--gray-200);
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--gray-600);
    transition: all 0.3s ease;
}

.step-indicator.active {
    background: var(--primary-color);
    color: white;
    transform: scale(1.05);
}

.step-indicator.completed {
    background: var(--success-color);
    color: white;
}

/* Question Container Styles */
.question-container {
    margin-bottom: 1.5rem;
}

.char-count-wrapper {
    font-size: 0.875rem;
    color: var(--gray-500);
    margin-top: 0.25rem;
    text-align: left;
}

/* Section Styles */
.section-content {
    animation: fadeIn 0.3s ease-in;
}

.intro-section {
    max-width: 900px;
    margin: 0 auto;
    text-align: -webkit-center;
}

.info-box {
    background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
    border: 2px solid #3b82f6;
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 32px;
    box-shadow: 0 4px 6px rgba(59, 130, 246, 0.1);
}

.info-box-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.info-box-header h3 {
    font-size: 1.25rem;
    font-weight: 700;
    color: #1e40af;
    margin: 0;
}

.info-icon {
    width: 28px;
    height: 28px;
    color: #3b82f6;
    flex-shrink: 0;
}

.info-box-intro {
    color: #1e40af;
    font-size: 1rem;
    line-height: 1.6;
    margin: 0 0 16px 0;
    font-weight: 500;
}

.info-box-note {
    color: #1e40af;
    font-size: 0.95rem;
    margin: 16px 0 0 0;
    font-weight: 600;
    text-align: center;
    padding-top: 16px;
    border-top: 1px solid #93c5fd;
}

.survey-sections-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
    margin: 16px 0;
}

.survey-section-badge {
    display: flex;
    align-items: center;
    gap: 12px;
    background: white;
    border: 2px solid #60a5fa;
    border-radius: 8px;
    padding: 12px 16px;
    transition: all 0.2s ease;
}

.survey-section-badge:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(59, 130, 246, 0.2);
    border-color: #3b82f6;
}

.section-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
}

.section-text {
    font-family: AammuFk;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.section-number {
    font-size: 0.75rem;
    color: #60a5fa;
    font-weight: 600;
}

.section-title {
    font-size: 0.95rem;
    color: #1e40af;
    font-weight: 700;
    line-height: 1.2;
}

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

.fade-in {
    animation: fadeIn 0.3s ease-in;
}

/* Checkbox Cards */
.checkbox-card {
    display: flex;
    align-items: center;
    padding: 15px;
    margin-bottom: 10px;
    border: 2px solid var(--gray-200);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    background: white;
}

.checkbox-card:hover {
    border-color: var(--primary-color);
    background: var(--gray-50);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.checkbox-card.selected {
    border-color: var(--primary-color);
    background: #eff6ff;
}

.checkbox-input {
    width: 20px;
    height: 20px;
    margin-right: 12px;
    cursor: pointer;
    accent-color: var(--primary-color);
}

.checkbox-label {
    flex: 1;
    font-weight: 500;
    color: var(--gray-700);
}

/* Ranking Cards */
.ranking-card {
    padding: 16px;
    margin-bottom: 10px;
    border: 2px solid var(--gray-200);
    border-radius: 8px;
    background: white;
    transition: all 0.2s ease;
}

.ranking-card:hover {
    border-color: var(--gray-300);
}

.ranking-card.selected {
    border-color: var(--primary-color);
    background: #eff6ff;
}

.ranking-checkbox {
    width: 20px;
    height: 20px;
    cursor: pointer;
    accent-color: var(--primary-color);
}

.ranking-select-container {
    min-width: 100px;
}

.ranking-select {
    width: 100%;
    padding: 8px 12px;
    border: 2px solid var(--gray-300);
    border-radius: 6px;
    background: white;
    font-size: 1rem;
    font-weight: 600;
    color: var(--gray-700);
    cursor: pointer;
    transition: all 0.2s ease;
}

.ranking-select:hover {
    border-color: var(--primary-color);
}

.ranking-select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(30, 64, 175, 0.1);
}

.ranking-select.error {
    border-color: var(--error-color);
    background: #fef2f2;
}

/* Form Inputs */
.text-input {
    width: 100%;
    padding: 12px;
    border: 2px solid var(--gray-300);
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
    transition: all 0.2s ease;
}

.text-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(30, 64, 175, 0.1);
}

.text-input.valid {
    border-color: var(--success-color);
}

.text-input.invalid {
    border-color: var(--error-color);
    background: #fef2f2;
}

textarea.text-input {
    resize: vertical;
    min-height: 100px;
}

.hidden {
    display: none !important;
}

/* Buttons */
.btn-primary,
.btn-secondary,
.btn-edit {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(30, 64, 175, 0.3);
}

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

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

.btn-secondary:hover {
    background: var(--gray-50);
    transform: translateY(-2px);
}

.btn-edit {
    background: transparent;
    color: var(--primary-color);
    border: 1px solid var(--primary-color);
    padding: 8px 16px;
    font-size: 0.875rem;
}

.btn-edit:hover {
    background: var(--primary-color);
    color: white;
}

/* Navigation */
.navigation-buttons {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    margin-top: 30px;
    padding-top: 30px;
    border-top: 2px solid var(--gray-200);
}

/* Review Section */
.review-section {
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
}

.review-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 15px;
    border-bottom: 2px solid var(--gray-200);
}

.review-content {
    color: var(--gray-700);
}

.review-content ul,
.review-content ol {
    margin-left: 20px;
}

/* Error Messages */
.error-message {
    margin-top: 10px;
    padding: 10px;
    border-radius: 6px;
}

.error-message p {
    color: var(--error-color);
    font-weight: 500;
}

/* Success Page */
.success-section {
    min-height: 500px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
}

.success-content {
    max-width: 600px;
    text-align: center;
}

.success-icon-wrapper {
    display: flex;
    justify-content: center;
    margin-bottom: 32px;
    animation: fadeInDown 0.6s ease-out;
}

.success-icon-circle {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 10px 40px rgba(16, 185, 129, 0.3);
    animation: bounceIn 0.8s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.success-checkmark {
    width: 48px;
    height: 48px;
    color: white;
    stroke-width: 3;
}

.checkmark-path {
    stroke-dasharray: 50;
    stroke-dashoffset: 50;
    animation: drawCheck 0.6s 0.3s ease-out forwards;
}

.success-title {
    font-size: 2.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, #059669 0%, #10b981 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 12px;
    animation: fadeInUp 0.6s 0.2s ease-out both;
}

.success-subtitle {
    font-size: 1.25rem;
    color: var(--gray-600);
    margin-bottom: 32px;
    animation: fadeInUp 0.6s 0.3s ease-out both;
}

.success-reference-card {
    background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
    border: 2px solid #86efac;
    border-radius: 16px;
    padding: 24px;
    margin-bottom: 32px;
    box-shadow: 0 4px 20px rgba(16, 185, 129, 0.1);
    animation: fadeInUp 0.6s 0.4s ease-out both;
}

.reference-label {
    font-size: 0.875rem;
    color: #059669;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 8px;
}

.reference-number {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    margin-bottom: 12px;
}

.reference-hash {
    font-size: 1.5rem;
    color: #10b981;
    font-weight: 700;
}

.reference-id {
    font-size: 1.75rem;
    font-family: 'Courier New', monospace;
    font-weight: 700;
    color: #059669;
    letter-spacing: 0.05em;
}

.reference-save-note {
    font-size: 0.875rem;
    color: var(--gray-600);
    font-style: italic;
}

.success-message {
    text-align: left;
    margin-bottom: 32px;
    animation: fadeInUp 0.6s 0.5s ease-out both;
}

/* RTL Support for Success Page */
[dir="rtl"] .reference-number {
    flex-direction: row-reverse;
}

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

[dir="rtl"] .message-primary,
[dir="rtl"] .message-secondary {
    text-align: right;
}

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

.message-primary {
    font-size: 1rem;
    line-height: 1.6;
    color: var(--gray-700);
    margin-bottom: 16px;
}

.message-secondary {
    font-size: 0.95rem;
    line-height: 1.6;
    color: var(--gray-600);
}

.btn-return {
    animation: fadeInUp 0.6s 0.6s ease-out both;
}

/* Success Animations */
@keyframes bounceIn {
    0% {
        transform: scale(0);
        opacity: 0;
    }
    50% {
        transform: scale(1.1);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes drawCheck {
    to {
        stroke-dashoffset: 0;
    }
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

/* Notifications */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 16px 24px;
    border-radius: 8px;
    background: white;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    z-index: 1000;
    transform: translateX(400px);
    transition: transform 0.3s ease;
    max-width: 400px;
}

.notification.show {
    transform: translateX(0);
}

.notification-success {
    border-left: 4px solid var(--success-color);
    color: var(--success-color);
}

.notification-error {
    border-left: 4px solid var(--error-color);
    color: var(--error-color);
}

.notification-info {
    border-left: 4px solid var(--primary-color);
    color: var(--primary-color);
}

/* Responsive Design */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }

    .main-content {
        padding: 20px;
    }

    .header h1 {
        font-size: 1.5rem;
    }

    .header p {
        font-size: 1rem;
    }

    .navigation-buttons {
        gap: 10px;
        margin-top: 20px;
        padding-top: 20px;
    }

    .btn-primary,
    .btn-secondary {
        padding: 8px 16px;
        font-size: 0.875rem;
    }

    .step-indicators {
        gap: 4px;
    }

    .step-indicator {
        font-size: 0.7rem;
        height: 32px;
        min-width: 32px;
    }

    .review-header {
        flex-direction: column;
        gap: 10px;
        align-items: flex-start;
    }

    .btn-edit {
        align-self: flex-end;
    }

    .survey-sections-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .survey-section-badge {
        padding: 10px 12px;
    }

    .section-icon {
        font-size: 1.25rem;
    }

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

@media (max-width: 480px) {
    .step-indicator {
        font-size: 0.65rem;
        height: 28px;
        min-width: 28px;
        padding: 2px;
    }

    .btn-primary,
    .btn-secondary {
        padding: 8px 12px;
        font-size: 0.8rem;
    }

    .btn-primary svg,
    .btn-secondary svg {
        width: 16px;
        height: 16px;
    }

    .navigation-buttons {
        gap: 8px;
    }

    .progress-info {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
}

/* Utility Classes */
.text-center {
    text-align: center;
}

.mb-2 {
    margin-bottom: 0.5rem;
}

.mb-4 {
    margin-bottom: 1rem;
}

.mb-6 {
    margin-bottom: 1.5rem;
}

.mb-8 {
    margin-bottom: 2rem;
}

.mt-4 {
    margin-top: 1rem;
}

.mt-6 {
    margin-top: 1.5rem;
}

.prose {
    max-width: 95ch;
}

.prose p {
    margin-bottom: 1rem;
}

/* Loading Animation */
@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.animate-spin {
    animation: spin 1s linear infinite;
}

/* ============================================
   RTL SUPPORT FOR DHIVEHI LANGUAGE
   ============================================ */

/* Dhivehi Fonts */
@font-face {
    font-family: 'AKRasmee';
    src: url('../fonts/AKRasmee.ttf') format('truetype');
    font-display: swap;
}

@font-face {
    font-family: 'AammuFk';
    src: url('../fonts/aammufkF.ttf') format('truetype');
    font-display: swap;
}

/* Dhivehi Font (Thaana Script) - Body Text */
.lang-dhivehi {
    font-family: 'AKRasmee', 'MV Waheed', 'Faruma', sans-serif;
}

/* Dhivehi Headings */
.lang-dhivehi h1,
.lang-dhivehi h2,
.lang-dhivehi h3,
.lang-dhivehi h4 {
    font-family: 'AammuFk', 'AKRasmee', sans-serif;
}

/* RTL Layout Adjustments */
[dir="rtl"] {
    direction: rtl;
    text-align: right;
}

[dir="rtl"] .header h1,
[dir="rtl"] .header p {
    text-align: center; /* Keep header centered */
}

/* RTL Progress Bar */
[dir="rtl"] .progress-fill {
    transform-origin: right;
}

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

[dir="rtl"] .step-indicators,
html[dir="rtl"] .step-indicators,
body.lang-dhivehi .step-indicators {
    flex-direction: row-reverse !important;
    direction: rtl !important;
}

[dir="rtl"] .step-indicator {
    margin-left: 0;
    margin-right: 0;
}

/* RTL Character Count */
[dir="rtl"] .char-count-wrapper {
    text-align: right;
}

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

[dir="rtl"] input[type="text"],
[dir="rtl"] input[type="email"],
[dir="rtl"] textarea,
[dir="rtl"] select {
    text-align: right;
    direction: rtl;
}

[dir="rtl"] input[type="checkbox"],
[dir="rtl"] input[type="radio"] {
    margin-left: 8px;
    margin-right: 0;
}

[dir="rtl"] .checkbox-label,
[dir="rtl"] .radio-label {
    padding-left: 0;
    padding-right: 28px;
}

[dir="rtl"] .checkbox-label::before,
[dir="rtl"] .radio-label::before {
    left: auto;
    right: 0;
}

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

[dir="rtl"] .btn svg {
    margin-left: 0;
    margin-right: 8px;
}

[dir="rtl"] .btn-primary svg:last-child {
    margin-right: 0;
    margin-left: 8px;
}

[dir="rtl"] .btn-secondary svg:first-child {
    margin-left: 8px;
    margin-right: 0;
}

/* RTL Ranking Section */
[dir="rtl"] .ranking-item {
    flex-direction: row-reverse;
}

[dir="rtl"] .rank-number {
    margin-left: 12px;
    margin-right: 0;
}

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

[dir="rtl"] .ranking-controls select {
    margin-left: 0;
    margin-right: 12px;
}

[dir="rtl"] .remove-rank {
    margin-left: 0;
    margin-right: 0;
}

/* RTL Review Section */
[dir="rtl"] .review-section h3 {
    text-align: right;
}

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

[dir="rtl"] .ranked-item .rank {
    margin-left: 12px;
    margin-right: 0;
}

/* RTL User Characterization */
[dir="rtl"] .role-grid {
    direction: rtl;
}

/* RTL Success Page */
[dir="rtl"] .success-content {
    text-align: center;
}

[dir="rtl"] .reference-number {
    direction: ltr; /* Keep reference number LTR */
}

/* Language Switcher Styles */
.language-switcher {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 1000;
}

[dir="rtl"] .language-switcher {
    right: auto;
    left: 20px;
}

.language-toggle-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    font-size: 14px;
    font-weight: 500;
}

.language-toggle-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.4);
    transform: translateY(-2px);
}

.language-icon {
    width: 20px;
    height: 20px;
}

.language-name {
    font-weight: 600;
}

/* Dhivehi Font Loading */
/* Font faces already declared above */

/* Ensure Dhivehi text displays correctly */
.lang-dhivehi p,
.lang-dhivehi label,
.lang-dhivehi button,
.lang-dhivehi select,
.lang-dhivehi option,
.lang-dhivehi input,
.lang-dhivehi textarea {
    font-family: 'AKRasmee', 'MV Waheed', 'Faruma', sans-serif;
}

/* Responsive RTL Adjustments */
@media (max-width: 768px) {
    .language-switcher {
        top: 10px;
        right: 10px;
    }
    
    [dir="rtl"] .language-switcher {
        right: auto;
        left: 10px;
    }
    
    .language-toggle-btn {
        padding: 8px 12px;
        font-size: 13px;
    }
    
    [dir="rtl"] .main-content {
        padding: 20px;
    }
}
