/* ==================== THEME VARIABLES ==================== */

/* Dark Mode (Default) */
:root,
:root[data-theme="dark"] {
    --primary-color: #3b82f6;
    --primary-hover: #2563eb;
    --secondary-color: #f43f5e;
    --bg-gradient: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    --card-bg: rgba(255, 255, 255, 0.08);
    --card-border: rgba(255, 255, 255, 0.15);
    --text-color: #f1f5f9;
    --text-muted: #94a3b8;
    --success-color: #10b981;
    --input-bg: rgba(0, 0, 0, 0.3);
    --font-family: 'Inter', system-ui, sans-serif;
}

/* Light Mode - Manual override */
:root[data-theme="light"] {
    --bg-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 50%, #f093fb 100%);
    --card-bg: rgba(255, 255, 255, 0.92);
    --card-border: rgba(99, 102, 241, 0.25);
    --text-color: #1e293b;
    --text-muted: #475569;
    --input-bg: rgba(255, 255, 255, 1);
}

/* Light Mode - Auto-detect from system preference (if no manual override) */
@media (prefers-color-scheme: light) {
    :root:not([data-theme]) {
        --bg-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 50%, #f093fb 100%);
        --card-bg: rgba(255, 255, 255, 0.92);
        --card-border: rgba(99, 102, 241, 0.25);
        --text-color: #1e293b;
        --text-muted: #475569;
        --input-bg: rgba(255, 255, 255, 1);
    }
}

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

body {
    font-family: var(--font-family);
    background: var(--bg-gradient);
    color: var(--text-color);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    line-height: 1.6;
}

.container {
    width: 100%;
    max-width: 600px;
    perspective: 1000px;
}

.card {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--card-border);
    border-radius: 20px;
    padding: 40px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    transition: transform 0.3s ease, opacity 0.3s ease;
}

h1,
h2,
h3 {
    margin-bottom: 20px;
    font-weight: 700;
    letter-spacing: -0.025em;
}

h1 {
    font-size: 2.5rem;
    background: linear-gradient(to right, #818cf8, #c4b5fd);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-align: center;
}

.form-group {
    margin-bottom: 25px;
}

label {
    display: block;
    margin-bottom: 10px;
    font-weight: 500;
    color: var(--text-color);
}

input[type="text"],
textarea {
    width: 100%;
    padding: 12px 16px;
    background: var(--input-bg);
    border: 1px solid var(--card-border);
    border-radius: 10px;
    color: var(--text-color);
    font-size: 1rem;
    outline: none;
    transition: all 0.2s;
}

input[type="text"]:focus,
textarea:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

.rating-container {
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-direction: row-reverse;
    /* For star CSS trick */
}

.rating-option {
    cursor: pointer;
    font-size: 2rem;
    color: var(--card-border);
    transition: color 0.2s, transform 0.1s;
}

.rating-option:hover,
.rating-option:hover~.rating-option,
.rating-option.selected,
.rating-option.selected~.rating-option {
    color: #fbbf24;
    transform: scale(1.1);
}

.btn {
    display: inline-block;
    width: 100%;
    padding: 14px 24px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
    text-decoration: none;
}

.btn:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 10px 20px -10px rgba(99, 102, 241, 0.5);
}

.btn-secondary {
    background: transparent;
    border: 1px solid var(--card-border);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.05);
}

.hidden {
    display: none;
}

.animate-fade-in {
    animation: fadeIn 0.5s ease-out forwards;
    opacity: 0;
}

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

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Response Success Icon */
.success-icon {
    font-size: 5rem;
    color: var(--success-color);
    text-align: center;
    margin-bottom: 20px;
    display: block;
}

/* Loading Spinner */
.loader {
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    border-top: 3px solid var(--primary-color);
    width: 24px;
    height: 24px;
    animation: spin 1s linear infinite;
    margin: 0 auto;
}

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

    100% {
        transform: rotate(360deg);
    }
}

.yes-no-group {
    display: flex;
    gap: 15px;
}

.yes-no-btn {
    flex: 1;
    padding: 12px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--card-border);
    border-radius: 10px;
    cursor: pointer;
    text-align: center;
    transition: all 0.2s;
}

.yes-no-btn.selected {
    background: var(--primary-color);
    border-color: var(--primary-color);
}

/* Admin Specific */
.admin-container {
    max-width: 1200px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: rgba(0, 0, 0, 0.2);
    padding: 20px;
    border-radius: 15px;
}

.table-responsive {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 20px;
}

th,
td {
    padding: 15px;
    text-align: left;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

th {
    color: var(--text-muted);
    font-size: 0.9rem;
    text-transform: uppercase;
}

.action-btn {
    padding: 5px 10px;
    border-radius: 5px;
    font-size: 0.8rem;
    margin-right: 5px;
    cursor: pointer;
}

.btn-edit {
    background: rgba(59, 130, 246, 0.2);
    color: #60a5fa;
    border: 1px solid rgba(59, 130, 246, 0.4);
}

.btn-delete {
    background: rgba(239, 68, 68, 0.2);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.4);
}

.nav-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

.rating-10-btn {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--card-border);
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: bold;
}

.rating-10-btn:hover,
.rating-10-btn.selected {
    background: var(--primary-color);
    color: white;
    transform: scale(1.1);
    border-color: var(--primary-color);
}

/* ==================== MOBILE RESPONSIVE ==================== */

/* Tablets and smaller */
@media (max-width: 768px) {
    body {
        padding: 15px;
        align-items: flex-start;
        padding-top: 30px;
    }

    .container {
        max-width: 100%;
    }

    .card {
        padding: 25px 20px;
        border-radius: 16px;
    }

    h1 {
        font-size: 1.8rem;
    }

    h2 {
        font-size: 1.4rem;
    }

    .form-group {
        margin-bottom: 20px;
    }

    .btn {
        padding: 16px 24px;
        font-size: 1rem;
    }

    /* Rating stars - bigger touch targets */
    .rating-option {
        font-size: 2.5rem;
        padding: 5px;
    }

    /* Rating 1-10 - bigger buttons */
    .rating-10-btn {
        width: 36px;
        height: 36px;
        font-size: 0.85rem;
    }

    /* Yes/No buttons */
    .yes-no-btn {
        padding: 16px;
        font-size: 1rem;
    }

    /* Admin tables */
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .nav-header {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }

    .nav-header h1 {
        font-size: 1.3rem;
    }

    table {
        font-size: 0.85rem;
    }

    th,
    td {
        padding: 10px 8px;
    }
}

/* Mobile phones */
@media (max-width: 480px) {
    body {
        padding: 10px;
        padding-top: 20px;
    }

    .card {
        padding: 20px 15px;
        border-radius: 14px;
    }

    h1 {
        font-size: 1.5rem;
    }

    h2 {
        font-size: 1.2rem;
    }

    label {
        font-size: 0.95rem;
    }

    input[type="text"],
    textarea {
        padding: 14px;
        font-size: 16px;
        /* Prevents zoom on iOS */
    }

    .btn {
        padding: 14px 20px;
        font-size: 1rem;
        border-radius: 10px;
    }

    /* Rating container - allow wrap */
    .rating-container {
        flex-wrap: wrap;
        gap: 8px;
        justify-content: center;
    }

    .rating-option {
        font-size: 2.2rem;
    }

    /* Rating 1-10 - wrap on small screens */
    .rating-10-btn {
        width: 32px;
        height: 32px;
        font-size: 0.8rem;
    }

    /* Yes/No stack on mobile */
    .yes-no-group {
        flex-direction: column;
    }

    .yes-no-btn {
        width: 100%;
    }

    /* Success icon smaller */
    .success-icon {
        font-size: 4rem;
    }

    /* Admin panel adjustments */
    .admin-container {
        padding: 0;
    }

    .action-btn {
        padding: 8px 12px;
        margin: 2px;
    }

    /* Tab buttons - full width */
    .tab-buttons {
        flex-direction: column;
    }

    .tab-btn {
        width: 100%;
        text-align: center;
    }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    .rating-option:hover {
        transform: none;
    }

    .rating-10-btn:hover {
        transform: none;
    }

    .btn:hover {
        transform: none;
    }

    /* Increase touch targets */
    .action-btn {
        min-width: 44px;
        min-height: 44px;
    }
}

/* ==================== RTL SUPPORT (Arabic, Hebrew, etc.) ==================== */

/* RTL language support */
html[dir="rtl"],
html[lang="ar"],
body.rtl {
    direction: rtl;
    text-align: right;
}

html[dir="rtl"] .rating-container,
html[lang="ar"] .rating-container,
body.rtl .rating-container {
    flex-direction: row-reverse;
}

html[dir="rtl"] .yes-no-group,
html[lang="ar"] .yes-no-group,
body.rtl .yes-no-group {
    flex-direction: row-reverse;
}

html[dir="rtl"] .nav-header,
html[lang="ar"] .nav-header,
body.rtl .nav-header {
    flex-direction: row-reverse;
}

html[dir="rtl"] input,
html[dir="rtl"] textarea,
html[lang="ar"] input,
html[lang="ar"] textarea,
body.rtl input,
body.rtl textarea {
    text-align: right;
    direction: rtl;
}

/* Arabic font improvements */
html[lang="ar"],
body.rtl {
    font-family: 'Noto Sans Arabic', 'Segoe UI', 'Inter', system-ui, sans-serif;
}