:root {
    /* Dark Mode (Default) - High Contrast Fixes */
    --bg-color: #0f172a;
    --card-bg: rgba(30, 41, 59, 0.7);
    --text-main: #ffffff;
    --text-muted: #cbd5e1; /* Lighter for better visibility */
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --input-bg: rgba(15, 23, 42, 0.8); /* Darker background for inputs */
    --border-color: rgba(255, 255, 255, 0.15);
}

* {
    transition: background .5s ease;
    transition: color .5s ease;
    transition: all .5s ease;
}

[data-theme="light"] {
    --bg-color: #f1f5f9;
    --card-bg: rgba(255, 255, 255, 0.85);
    --text-main: #1e293b;
    --text-muted: #475569; /* Darker for light mode visibility */
    --input-bg: #ffffff;
    --border-color: rgba(0, 0, 0, 0.1);
}

body {
    background-color: var(--bg-color);
    background-image: 
        radial-gradient(at 0% 0%, rgba(59, 130, 246, 0.2) 0, transparent 50%), 
        radial-gradient(at 100% 100%, rgba(139, 92, 246, 0.2) 0, transparent 50%);
    color: var(--text-main);
    font-family: 'Inter', sans-serif;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Typography & Links */
h1, h2, h3, h4, h5, h6 { color: var(--text-main); font-weight: 700; }
.text-muted { color: var(--text-muted) !important; opacity:0.75; }
a { color: var(--primary); text-decoration: none; transition: 0.2s; }
a:hover { color: var(--primary-hover); text-decoration: underline; }

/* Unified Glass Card */
.container-center {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.glass-card {
    width: 100%;
    max-width: 450px; /* Standardized Width */
    background: var(--card-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
    border-radius: 24px;
    padding: 2.5rem;
}

/* Inputs */
.form-control, .input-group-text {
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 12px;
}
.form-control:focus {
    background: var(--input-bg);
    color: var(--text-main);
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.15);
}
.input-group-text { border-right: none; color: var(--text-muted); }
.form-control { border-left: none; }
.form-control::placeholder { color: var(--text-muted); opacity: 0.7; }

/* Buttons */
.btn-primary {
    background-color: var(--primary);
    border: none;
    padding: 12px;
    font-weight: 600;
}
.btn-primary:hover { background-color: var(--primary-hover); }

/* Theme Toggle */
.theme-toggle {
    position: fixed;
    top: 20px;
    right: 20px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    width: 45px;
    height: 45px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    cursor: pointer;
    z-index: 1000;
}

.btn-outline-light:hover {
    color:black !important;
}

/* Password reveal button (assets/password-toggle.js).
   .input-group-text drops its right border above, which is right for a leading
   add-on but leaves a trailing one open-sided — put it back. */
.ay-reveal {
    border-left: none;
    border-right: 1px solid var(--border-color);
    cursor: pointer;
}
.ay-reveal:hover { color: var(--text-main); }

/* International phone input (assets/phone-input.js) */
.ay-country-btn {
    border-left: none;
    border-right: none;
    cursor: pointer;
    padding-left: 8px;
    padding-right: 8px;
}
.ay-country-btn:hover { background: var(--input-bg); filter: brightness(1.25); }

.ay-country-panel {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 1050;
    width: min(320px, 100%);
    margin-top: 4px;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.45);
    overflow: hidden;
}
.ay-country-panel.open { display: block; }

.ay-country-search {
    width: 100%;
    border: none;
    border-bottom: 1px solid var(--border-color);
    background: var(--input-bg);
    color: var(--text-main);
    padding: 10px 12px;
    outline: none;
}

.ay-country-list { max-height: 260px; overflow-y: auto; }

.ay-country-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 8px 12px;
    background: transparent;
    border: none;
    color: var(--text-main);
    text-align: left;
    font-size: 0.9rem;
    cursor: pointer;
}
.ay-country-item:hover, .ay-country-item:focus {
    background: rgba(59, 130, 246, 0.18);
    outline: none;
}
.ay-country-name { flex: 1; }
.ay-country-dial { color: var(--text-muted); font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- Responsive
   The layout was built at desktop width and never narrowed: .glass-card's
   2.5rem padding plus .container-center's 20px leaves ~240px of usable space on
   a 360px phone, which is what made the denser pages (services, admin, 2FA)
   overflow sideways. */

/* Nothing may push the page itself sideways — wide content scrolls in its own
   container instead (see .table-responsive and .chart-scroll). */
body { overflow-x: hidden; }
img { max-width: 100%; }

@media (max-width: 768px) {
    .glass-card { padding: 1.75rem; }
}

@media (max-width: 576px) {
    .container-center { padding: 12px; }
    .glass-card {
        padding: 1.25rem;
        border-radius: 18px;
        /* The desktop shadow costs paint time and reads as muddy on small,
           low-contrast screens. */
        box-shadow: 0 10px 24px rgba(0, 0, 0, 0.35);
    }
    .form-control, .input-group-text { padding: 10px; }

    /* Fixed at 20px it sat on top of page headings on narrow screens. */
    .theme-toggle { top: 12px; right: 12px; width: 38px; height: 38px; }

    /* Bootstrap's h1–h3 scale is tuned for desktop and wraps badly at 360px. */
    h2 { font-size: 1.5rem; }
    h3 { font-size: 1.3rem; }
}

/* A row of buttons that must not squash its siblings into slivers. Applied to
   the page headers that pair a title with an action group. */
.header-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
