/* =========================
   THEME TOKENS
   ========================= */

/* Light theme is DEFAULT (when no data-theme is set) */
:root {
    /* Light palette */
    --bg-page: #f3f4f6;
    --bg-surface: #e5e7eb;
    --bg-card: #ffffff;
    --bg-card-soft: #f9fafb;

    --border-subtle: rgba(148, 163, 184, 0.45);
    --border-strong: rgba(148, 163, 184, 0.7);

    --text-main: #0f172a;
    --text-muted: #4b5563;
    --text-soft: #6b7280;

    --accent-main: #6366f1;   /* indigo */
    --accent-main-soft: rgba(99, 102, 241, 0.10);
    --accent-main-border: rgba(79, 70, 229, 0.9);

    --accent-good: #16a34a;
    --accent-good-soft: rgba(22, 163, 74, 0.10);
    --accent-good-border: rgba(22, 163, 74, 0.8);

    --accent-warn: #f59e0b;
    --accent-warn-soft: rgba(245, 158, 11, 0.12);
    --accent-warn-border: rgba(245, 158, 11, 0.8);

    --accent-bad: #dc2626;
    --accent-bad-soft: rgba(220, 38, 38, 0.08);
    --accent-bad-border: rgba(220, 38, 38, 0.85);

    --radius-card: 18px;
    --radius-pill: 999px;

    --shadow-soft: 0 18px 40px rgba(15, 23, 42, 0.14);
    --shadow-subtle: 0 10px 25px rgba(15, 23, 42, 0.08);

    --container-width: 1180px;
}

/* DARK theme overrides */
:root[data-theme="dark"] {
    --bg-page: #050712;
    --bg-surface: #060818;
    --bg-card: #070a1f;
    --bg-card-soft: #090d27;

    --border-subtle: rgba(148, 163, 184, 0.22);
    --border-strong: rgba(148, 163, 184, 0.45);

    --text-main: #e5e7eb;
    --text-muted: #9ca3af;
    --text-soft: #6b7280;

    --accent-main: #6366f1;
    --accent-main-soft: rgba(99, 102, 241, 0.16);
    --accent-main-border: rgba(129, 140, 248, 0.8);

    --accent-good: #22c55e;
    --accent-good-soft: rgba(34, 197, 94, 0.16);
    --accent-good-border: rgba(34, 197, 94, 0.7);

    --accent-warn: #fbbf24;
    --accent-warn-soft: rgba(251, 191, 36, 0.18);
    --accent-warn-border: rgba(251, 191, 36, 0.8);

    --accent-bad: #f97373;
    --accent-bad-soft: rgba(248, 113, 113, 0.16);
    --accent-bad-border: rgba(248, 113, 113, 0.8);

    --shadow-soft: 0 16px 40px rgba(15, 23, 42, 0.8);
    --shadow-subtle: 0 10px 25px rgba(15, 23, 42, 0.6);
}

/* =========================
   GLOBAL RESET + BASE TEXT
   ========================= */

*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: linear-gradient(145deg, var(--bg-page), var(--bg-surface));
    color: var(--text-main);
}

/* Make sure all common text respects theme colors */
body,
p,
span,
label,
input,
select,
textarea,
button,
h1,
h2,
h3,
h4,
h5,
h6,
small,
strong,
em,
li,
td,
th {
    color: var(--text-main);
}

/* Links */
a,
a:visited {
    color: #4f46e5;
    text-decoration: none;
}
a:hover {
    color: #4338ca;
    text-decoration: underline;
}

:root[data-theme="dark"] a,
:root[data-theme="dark"] a:visited {
    color: #c7d2fe;
}
:root[data-theme="dark"] a:hover {
    color: #e5e7eb;
}

/* Placeholder text */
::placeholder {
    color: rgba(148, 163, 184, 0.7);
}

/* =========================
   RTL BASE SUPPORT
   ========================= */

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

/* When in RTL, a .text-right might actually need to flip */
html[dir="rtl"] .text-right {
    text-align: left;
}

/* =========================
   LAYOUT
   ========================= */

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

.page-main {
    flex: 1 1 auto;
}

.page-container {
    width: 100%;
    max-width: var(--container-width);
    margin: 0 auto;
    padding: 1.5rem 1.25rem 3rem;
}

/* =========================
   TYPOGRAPHY UTILITIES
   ========================= */

.text-soft {
    color: var(--text-soft);
}

.text-muted {
    color: var(--text-muted);
}

.text-accent {
    color: var(--accent-main);
}

.text-warning-soft {
    color: var(--accent-warn);
}

/* Logo text used in auth pages */

.logo-tag {
    font-weight: 800;
    letter-spacing: 0.16em;
    font-size: 0.8rem;
    text-transform: uppercase;
    color: var(--text-muted);
}

.logo-title {
    font-size: 1.2rem;
    font-weight: 600;
    margin-top: 0.4rem;
}

/* =========================
   HEADER / NAVBAR
   ========================= */

.site-header {
    border-bottom: 1px solid var(--border-subtle);
    background: var(--bg-card-soft);
    backdrop-filter: blur(10px);
}

:root[data-theme="dark"] .site-header {
    background: rgba(6, 8, 24, 0.96);
}

.site-header-inner {
    max-width: var(--container-width);
    margin: 0 auto;
    padding: 0.65rem 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.site-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.site-brand-mark {
    width: 30px;
    height: 30px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--accent-main), var(--accent-good));
    display: flex;
    align-items: center;
    justify-content: center;
    color: #f9fafb;
    font-size: 0.9rem;
    font-weight: 700;
}

.site-brand-text {
    display: flex;
    flex-direction: column;
}

.site-brand-title {
    font-size: 0.95rem;
    font-weight: 600;
}

.site-brand-sub {
    font-size: 0.7rem;
    color: var(--text-soft);
}

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

.site-nav-links {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.85rem;
}

.site-nav-links a {
    color: var(--text-muted);
    text-decoration: none;
    padding: 0.25rem 0.5rem;
    border-radius: 999px;
}
.site-nav-links a:hover {
    background: rgba(148, 163, 184, 0.16);
    color: var(--text-main);
}

.site-nav-right {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

/* Language switcher */
.lang-switcher {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.75rem;
    margin-left: auto;      /* pushes language buttons to far right in LTR */
}

/* In RTL, flip the auto margin so it still goes to the far "edge" */
html[dir="rtl"] .lang-switcher {
    margin-left: 0;
    margin-right: auto;
}


.lang-switcher a {
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    border: 1px solid var(--border-subtle);
    color: var(--text-muted);
    text-decoration: none;
}

.lang-switcher a:hover {
    background: rgba(148, 163, 184, 0.16);
    color: var(--text-main);
}

.lang-switcher a.active {
    border-color: var(--accent-main-border);
    background: var(--accent-main-soft);
    color: var(--accent-main);
    font-weight: 600;
}

/* RTL adjustments for header/nav */
html[dir="rtl"] .site-header-inner {
    flex-direction: row-reverse;
}

html[dir="rtl"] .site-brand {
    flex-direction: row-reverse;
}

html[dir="rtl"] .site-nav {
    flex-direction: row-reverse;
}

html[dir="rtl"] .site-nav-links {
    flex-direction: row-reverse;
}

html[dir="rtl"] .site-brand-text {
    text-align: right;
}

/* Theme toggle button */

.theme-toggle {
    border-radius: var(--radius-pill);
    border: 1px solid var(--border-subtle);
    background: transparent;
    padding: 0.25rem 0.7rem;
    font-size: 0.8rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    color: var(--text-muted);
}

.theme-toggle:hover {
    border-color: var(--accent-main-border);
}

.theme-toggle-icon {
    font-size: 0.95rem;
}

/* =========================
   HERO + CARDS
   ========================= */

.hero {
    border-radius: 24px;
    padding: 2.2rem 1.8rem;
    margin-bottom: 2rem;
    border: 1px solid var(--border-subtle);
    background:
        radial-gradient(circle at top left, var(--bg-card-soft) 0, transparent 55%),
        linear-gradient(135deg, var(--bg-surface), var(--bg-card));
    box-shadow: var(--shadow-soft);
}

:root[data-theme="dark"] .hero {
    background:
        radial-gradient(circle at top left, #111827 0, transparent 65%),
        radial-gradient(circle at center right, rgba(99, 102, 241, 0.26) 0, transparent 55%),
        linear-gradient(135deg, #020617 0, #020617 100%);
}

.hero-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) minmax(0, 1.1fr);
    gap: 1.9rem;
}

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

.card {
    border-radius: var(--radius-card);
    border: 1px solid var(--border-subtle);
    background: var(--bg-card);
    box-shadow: var(--shadow-subtle);
    padding: 1.1rem 1.2rem;
    color: var(--text-main);
}

/* Make sure text inside cards inherits readable color */
.card * {
    color: inherit;
}

.card-header {
    padding-bottom: 0.7rem;
    margin-bottom: 0.7rem;
    border-bottom: 1px solid rgba(148, 163, 184, 0.22);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-header-title {
    font-size: 0.95rem;
    font-weight: 600;
}

.card-header-sub {
    font-size: 0.8rem;
    color: var(--text-soft);
}

/* Secondary cards row (metrics) */

.grid-3-metrics {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.9rem;
}

@media (max-width: 900px) {
    .grid-3-metrics {
        grid-template-columns: 1fr;
    }
}

.metric-card {
    padding: 0.95rem 1rem;
    border-radius: 16px;
    border: 1px solid var(--border-subtle);
    background: var(--bg-card);
    box-shadow: var(--shadow-subtle);
}

.metric-label {
    font-size: 0.8rem;
    color: var(--text-soft);
    margin-bottom: 0.25rem;
}

.metric-value {
    font-size: 1.3rem;
    font-weight: 600;
}

.metric-chip {
    display: inline-flex;
    align-items: center;
    border-radius: var(--radius-pill);
    font-size: 0.7rem;
    padding: 0.18rem 0.5rem;
    background: var(--accent-main-soft);
    color: var(--accent-main);
}

/* =========================
   BUTTONS
   ========================= */

.btn {
    border-radius: var(--radius-pill);
    border: 0;
    padding: 0.55rem 1.2rem;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    transition:
        transform 0.07s ease-out,
        box-shadow 0.1s ease-out,
        filter 0.07s ease-out,
        background 0.1s ease-out;
}

.btn-primary {
    background: linear-gradient(135deg, #6366f1, #22c55e);
    color: #f9fafb;
    box-shadow: 0 10px 28px rgba(15, 23, 42, 0.35);
}

:root[data-theme="dark"] .btn-primary {
    color: #e5e7eb;
    box-shadow: 0 10px 28px rgba(15, 23, 42, 0.9);
}

.btn-primary:hover {
    filter: brightness(1.04);
    transform: translateY(-1px);
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border-subtle);
    color: var(--text-main);
}

:root[data-theme="dark"] .btn-outline {
    color: var(--text-main);
}

.btn-outline:hover {
    border-color: var(--accent-main);
}

.btn-full {
    width: 100%;
}

/* =========================
   PILLS / BADGES
   ========================= */

.pill {
    border-radius: var(--radius-pill);
    border: 1px solid var(--border-subtle);
    padding: 0.3rem 0.75rem;
    font-size: 0.75rem;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    background: var(--bg-card-soft);
}

.pill-good {
    border-color: var(--accent-good-border);
    background: var(--accent-good-soft);
    color: var(--accent-good);
}

.pill-bad {
    border-color: var(--accent-bad-border);
    background: var(--accent-bad-soft);
    color: var(--accent-bad);
}

.pill-warn {
    border-color: var(--accent-warn-border);
    background: var(--accent-warn-soft);
    color: var(--accent-warn);
}

.pill-small {
    font-size: 0.7rem;
    padding: 0.25rem 0.6rem;
}

/* =========================
   SEARCH
   ========================= */

/* Vertical stack for: text input on top, dropdown row below */
.search-stack {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

/* New simple horizontal search bar (used in stores.php, reports.php) */
.search-bar {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.search-bar input[type="text"] {
    flex: 1;
    padding: 0.5rem 0.75rem;
    border-radius: 0.75rem;
    border: 1px solid var(--border-subtle);
    background: var(--bg-card);
    color: var(--text-main);
    font-size: 0.9rem;
    outline: none;
}

.search-bar input[type="text"]:focus {
    border-color: var(--accent-main-border);
    box-shadow: 0 0 0 1px var(--accent-main-soft);
}

.search-bar input[type="text"]::placeholder {
    color: rgba(148, 163, 184, 0.8);
}

.search-bar button {
    padding: 0.5rem 1.1rem;
    border-radius: 0.75rem;
    border: 0;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    background: var(--accent-main);
    color: #f9fafb;
    box-shadow: 0 6px 16px rgba(15, 23, 42, 0.3);
    transition:
        transform 0.06s ease-out,
        box-shadow 0.08s ease-out,
        filter 0.06s ease-out;
}

.search-bar button:hover {
    filter: brightness(1.04);
    transform: translateY(-1px);
}

/* Existing advanced search row (if used elsewhere) */
.search-row {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(0, 1.1fr) minmax(0, 0.9fr);
    gap: 0.75rem;
    margin-bottom: 0.9rem;
}

@media (max-width: 900px) {
    .search-row {
        grid-template-columns: 1fr;
    }

    .search-bar {
        flex-direction: column;
        align-items: stretch;
    }
}

.search-input-pill {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    border-radius: var(--radius-pill);
    border: 1px solid var(--border-subtle);
    background: var(--bg-card);
    padding: 0.32rem 0.8rem;
}

.search-input-pill input {
    border: 0;
    flex: 1;
    font-size: 0.9rem;
    background: transparent;
    color: var(--text-main);
    outline: none;
}

.select-soft {
    width: 100%;
    border-radius: var(--radius-pill);
    border: 1px solid var(--border-subtle);
    background: var(--bg-card);
    color: var(--text-main);
    padding: 0.45rem 0.9rem;
    font-size: 0.85rem;
    outline: none;
}

/* Old compact search-row variant (kept for compatibility, if still used) */
.search-row-compact {
    display: grid;
    grid-template-columns: minmax(0, 2.2fr)
                           minmax(0, 1.1fr)
                           minmax(0, 1.1fr)
                           minmax(0, 1.1fr)
                           auto;
    gap: 0.5rem;
    align-items: stretch;
}

.search-row-compact .search-cell select,
.search-row-compact .search-cell .search-input-pill {
    width: 100%;
}

@media (max-width: 768px) {
    .search-row-compact {
        grid-template-columns: 1fr;
    }

    .search-row-compact .search-cell-button button {
        width: 100%;
    }
}

/* Hero dropdown single-line layout: Country / State / City / Button */
.search-row-dropdowns {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr auto;
    gap: 0.6rem;
    align-items: center;
    width: 100%;
}

.dropdown-cell select,
.dropdown-cell button {
    width: 100%;
}

/* Mobile responsive for hero dropdowns */
@media (max-width: 768px) {
    .search-row-dropdowns {
        grid-template-columns: 1fr;
    }
}

/* =========================
   LISTS
   ========================= */

.list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.list-item {
    padding: 0.75rem 0;
    border-bottom: 1px solid rgba(148, 163, 184, 0.18);
}

.list-item:last-child {
    border-bottom: 0;
}

.list-item-main {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
}

.list-item-title {
    font-size: 0.9rem;
    font-weight: 600;
}

.list-item-meta {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.list-item-desc {
    font-size: 0.8rem;
    color: var(--text-soft);
    margin: 0.22rem 0 0.22rem;
}

/* =========================
   SIMPLE GRIDS
   ========================= */

.grid-2 {
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
    gap: 1.1rem;
}

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

/* =========================
   AUTH PAGES
   ========================= */

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

.auth-card {
    max-width: 430px;
    width: 100%;
    margin: 2.2rem auto 2.8rem;
}

/* =========================
   FORMS
   ========================= */

.form-field {
    margin-bottom: 0.9rem;
}

.form-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 0.3rem;
    display: block;
}

.form-input,
.form-select,
textarea.form-input {
    width: 100%;
    border-radius: 12px;
    border: 1px solid var(--border-subtle);
    background: var(--bg-card);
    color: var(--text-main);
    padding: 0.55rem 0.75rem;
    font-size: 0.9rem;
    outline: none;
    resize: vertical;
}

.form-input:focus,
.form-select:focus,
textarea.form-input:focus {
    border-color: var(--accent-main-border);
    box-shadow: 0 0 0 1px var(--accent-main-soft);
}

.form-help {
    font-size: 0.75rem;
    color: var(--text-soft);
    margin-top: 0.1rem;
}

.form-row-2 {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
}

@media (max-width: 600px) {
    .form-row-2 {
        grid-template-columns: 1fr;
    }
}

/* =========================
   UNIFIED COMMENT/REVIEW FORM
   ========================= */

.form-block {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-top: 0.5rem;
}

.form-block textarea {
    width: 100%;
    border-radius: 14px;
    border: 1px solid var(--border-subtle);
    background: var(--bg-card);
    padding: 0.85rem 1rem;
    font-size: 0.9rem;
    resize: vertical;
    outline: none;
    color: var(--text-main);
    transition: 0.15s ease-in-out;
}

.form-block textarea:focus {
    border-color: var(--accent-main-border);
    box-shadow: 0 0 0 2px var(--accent-main-soft);
}

/* Modern primary submit button for forms */
.form-submit-btn {
    background: linear-gradient(135deg, #6366f1, #22c55e);
    border: none;
    border-radius: var(--radius-pill);
    padding: 0.65rem 1.4rem;
    font-size: 0.9rem;
    font-weight: 600;
    color: #fff;
    cursor: pointer;
    width: fit-content;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.2);
    transition: 0.15s ease;
}

.form-submit-btn:hover {
    transform: translateY(-2px);
    filter: brightness(1.04);
}

/* =========================
   STAR RATING 2.0 (YELLOW GLOW)
   ========================= */

.star-rating {
    display: inline-flex;
    gap: 0.3rem;
    cursor: pointer;
}

.star-rating .star {
    font-size: 1.8rem;
    color: #d1d5db;
    transition: color 0.15s, transform 0.1s, text-shadow 0.15s;
}

.star-rating .star.active {
    color: #facc15;
    text-shadow: 0 0 10px rgba(250, 204, 21, 0.7);
}

.star-rating .star:hover {
    color: #fde047;
    transform: scale(1.05);
}

/* =========================
   ALERTS
   ========================= */

.alert {
    border-radius: 12px;
    padding: 0.6rem 0.8rem;
    font-size: 0.8rem;
    margin-bottom: 0.9rem;
}

.alert-error {
    background: var(--accent-bad-soft);
    border: 1px solid var(--accent-bad-border);
    color: var(--accent-bad);
}

.alert-success {
    background: var(--accent-good-soft);
    border: 1px solid var(--accent-good-border);
    color: var(--accent-good);
}

/* =========================
   INTERNAL LINK UTILITY
   ========================= */

.link {
    color: #4f46e5;
    text-decoration: none;
}
.link:hover {
    text-decoration: underline;
}

:root[data-theme="dark"] .link {
    color: #c7d2fe;
}

/* =========================
   UTILITIES
   ========================= */

.flex {
    display: flex;
}

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

.flex-wrap {
    flex-wrap: wrap;
}

.gap-2 {
    gap: 0.5rem;
}

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

.mt-2 {
    margin-top: 0.5rem;
}

.mb-0 {
    margin-bottom: 0;
}

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

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

.mb-3 {
    margin-bottom: 0.75rem;
}

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

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

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

/* =========================
   FOOTER
   ========================= */

.site-footer {
    border-top: 1px solid var(--border-subtle);
    padding: 1rem 1.2rem 1.4rem;
    font-size: 0.8rem;
    color: var(--text-soft);
    background: var(--bg-card-soft);
}
