/*
 * SMS Gateway: admin panel and API docs.
 * Plain CSS on purpose: deploying the gateway requires no Node.js build step.
 */

:root {
    --bg: #f6f7f9;
    --surface: #ffffff;
    --surface-muted: #f1f3f6;
    --border: #e1e5ea;
    --text: #1b1f24;
    --text-muted: #5d6673;
    --primary: #2457d6;
    --primary-hover: #1c46ad;
    --primary-soft: #e8eefc;
    --success: #13795b;
    --success-soft: #e3f5ee;
    --warning: #9a6200;
    --warning-soft: #fdf3dd;
    --danger: #c0352b;
    --danger-soft: #fbe9e7;
    --info: #3a5a99;
    --info-soft: #e9eef8;
    --code-bg: #0f1720;
    --code-text: #e3e8ef;
    --radius: 10px;
    --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
    --font: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Noto Sans Arabic", sans-serif;
    --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0f1216;
        --surface: #171b21;
        --surface-muted: #1e232b;
        --border: #2b313a;
        --text: #e6e9ee;
        --text-muted: #9aa3af;
        --primary: #6b93ff;
        --primary-hover: #8eabff;
        --primary-soft: #1d2a4a;
        --success: #4cc79b;
        --success-soft: #12312a;
        --warning: #f0b44c;
        --warning-soft: #3a2c10;
        --danger: #ff7b70;
        --danger-soft: #3b1c1a;
        --info: #93b0ec;
        --info-soft: #1c2740;
        --code-bg: #0a0d11;
        --shadow: none;
        color-scheme: dark;
    }
}

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

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 15px/1.55 var(--font);
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { line-height: 1.25; margin: 0 0 .75rem; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 1rem; }

code, pre { font-family: var(--mono); font-size: .86em; }
:not(pre) > code { background: var(--surface-muted); border: 1px solid var(--border); border-radius: 5px; padding: .08em .35em; overflow-wrap: anywhere; }
pre { background: var(--code-bg); color: var(--code-text); border-radius: var(--radius); padding: 1rem 1.1rem; overflow-x: auto; margin: 0 0 1rem; line-height: 1.5; }

/* Layout */
.topbar { background: var(--surface); border-bottom: 1px solid var(--border); }
.topbar-inner { max-width: 1200px; margin: 0 auto; padding: .75rem 16px; display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1.5rem; }
.brand { font-weight: 700; color: var(--text); display: flex; align-items: center; gap: .5rem; }
.brand:hover { text-decoration: none; }
.brand-mark { width: 26px; height: 26px; border-radius: 7px; background: var(--primary); color: #fff; display: grid; place-items: center; font-size: .8rem; }
.nav { display: flex; flex-wrap: wrap; gap: .25rem; flex: 1; }
.nav a { color: var(--text-muted); padding: .35rem .65rem; border-radius: 7px; font-weight: 500; }
.nav a:hover { background: var(--surface-muted); text-decoration: none; color: var(--text); }
.nav a.active { background: var(--primary-soft); color: var(--primary); }
.topbar form { margin: 0; }

.container { max-width: 1200px; margin: 0 auto; padding: 1.5rem 16px 3rem; }
.page-header { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: 1.25rem; }
.page-header h1 { margin: 0; }
.page-header p { margin: .25rem 0 0; color: var(--text-muted); }
.stack > * + * { margin-top: 1.25rem; }
.row { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.muted { color: var(--text-muted); }
.small { font-size: .85rem; }
.mono { font-family: var(--mono); font-size: .88em; }
.nowrap { white-space: nowrap; }
.text-right { text-align: right; }

/* Cards & stats */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.25rem; min-width: 0; }
.card > :last-child { margin-bottom: 0; }
.card-header { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .5rem; margin-bottom: .9rem; }
.card-header h2 { margin: 0; }
.grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.grid-2 { display: grid; gap: 1.25rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); }
.stat { padding: 1rem 1.1rem; }
.stat-label { color: var(--text-muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
.stat-value { font-size: 1.6rem; font-weight: 700; margin-top: .2rem; font-variant-numeric: tabular-nums; }
.stat-value.success { color: var(--success); }
.stat-value.danger { color: var(--danger); }
.stat-value.warning { color: var(--warning); }

/* Tables */
.table-wrap { overflow-x: auto; margin: 0 -1.25rem; padding: 0 1.25rem; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { text-align: left; padding: .6rem .7rem; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--text-muted); font-size: .76rem; text-transform: uppercase; letter-spacing: .04em; font-weight: 600; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--surface-muted); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.empty { text-align: center; color: var(--text-muted); padding: 2rem 1rem; }
dl.details { display: grid; grid-template-columns: minmax(120px, 210px) 1fr; gap: .55rem 1rem; margin: 0; }
dl.details dt { color: var(--text-muted); font-weight: 500; }
dl.details dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

/* Badges */
.badge { display: inline-block; padding: .12rem .55rem; border-radius: 999px; font-size: .75rem; font-weight: 600; white-space: nowrap; background: var(--surface-muted); color: var(--text-muted); border: 1px solid var(--border); }
.badge-success { background: var(--success-soft); color: var(--success); border-color: transparent; }
.badge-danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.badge-warning { background: var(--warning-soft); color: var(--warning); border-color: transparent; }
.badge-info { background: var(--info-soft); color: var(--info); border-color: transparent; }
.badge-primary { background: var(--primary-soft); color: var(--primary); border-color: transparent; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; padding: .5rem .95rem; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: 600 .9rem/1.2 var(--font); cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--surface-muted); text-decoration: none; }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-danger { color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); }
.btn-sm { padding: .3rem .6rem; font-size: .8rem; }
.btn-link { border: 0; background: none; color: var(--primary); padding: 0; font-weight: 500; }
.btn-link:hover { background: none; text-decoration: underline; }
.inline-form { display: inline; margin: 0; }

/* Forms */
.form { max-width: 720px; }
.field { margin-bottom: 1.1rem; }
.field label, .label { display: block; font-weight: 600; margin-bottom: .35rem; font-size: .9rem; }
.field .hint { color: var(--text-muted); font-size: .82rem; margin-top: .3rem; }
.field .error { color: var(--danger); font-size: .84rem; margin-top: .3rem; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=tel], select, textarea {
    width: 100%; padding: .55rem .7rem; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); font: inherit;
}
textarea { min-height: 110px; resize: vertical; }
textarea.code { font-family: var(--mono); font-size: .85rem; min-height: 360px; }
.checkbox { display: flex; gap: .55rem; align-items: flex-start; margin-bottom: .45rem; font-weight: 400; }
.checkbox input { margin-top: .3rem; }
.form-actions { display: flex; gap: .6rem; flex-wrap: wrap; margin-top: 1.5rem; }
fieldset.card { margin: 0; }
fieldset.card > legend { float: left; width: 100%; padding: 0; margin-bottom: .9rem; }
fieldset.card > legend + * { clear: both; }
details.card > summary { cursor: pointer; }
[hidden] { display: none !important; }
.preset-list { display: flex; flex-wrap: wrap; gap: .5rem; }
.filters { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); align-items: end; }
.filters .field { margin: 0; }

/* Alerts */
.alert { border-radius: var(--radius); padding: .85rem 1rem; margin-bottom: 1.25rem; border: 1px solid transparent; }
.alert-success { background: var(--success-soft); color: var(--success); }
.alert-danger { background: var(--danger-soft); color: var(--danger); }
.alert-warning { background: var(--warning-soft); color: var(--warning); }
.alert-info { background: var(--info-soft); color: var(--info); }
.alert ul { margin: .3rem 0 0; padding-left: 1.2rem; }

.token-box { background: var(--warning-soft); border: 1px solid var(--warning); border-radius: var(--radius); padding: 1rem; margin-bottom: 1.25rem; }
.token-box strong { color: var(--warning); }
.token-value { display: flex; gap: .5rem; margin-top: .6rem; flex-wrap: wrap; }
.token-value code { flex: 1; min-width: 0; background: var(--surface); padding: .55rem .7rem; font-size: .9rem; word-break: break-all; }

/* Pagination */
.pagination { display: flex; justify-content: space-between; align-items: center; gap: .75rem; margin-top: 1rem; flex-wrap: wrap; }

/* Auth & landing */
.center-screen { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem 16px; }
.auth-card { width: 100%; max-width: 400px; }
.auth-card .brand { justify-content: center; margin-bottom: 1.25rem; font-size: 1.1rem; }
.landing { max-width: 640px; text-align: center; }
.landing .row { justify-content: center; }

/* Docs */
.docs { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 2rem; max-width: 1200px; margin: 0 auto; padding: 1.5rem 16px 4rem; }
.docs-nav { position: sticky; top: 1rem; align-self: start; max-height: calc(100vh - 2rem); overflow-y: auto; }
.docs-nav a { display: block; color: var(--text-muted); padding: .28rem .6rem; border-radius: 6px; font-size: .9rem; }
.docs-nav a:hover { background: var(--surface-muted); color: var(--text); text-decoration: none; }
.docs-nav .group { font-size: .74rem; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); font-weight: 700; margin: 1rem 0 .3rem .6rem; }
.docs-content section { margin-bottom: 2.75rem; scroll-margin-top: 1rem; }
.docs-content h2 { font-size: 1.3rem; padding-bottom: .4rem; border-bottom: 1px solid var(--border); margin-bottom: 1rem; }
.docs-content h3 { margin-top: 1.5rem; }
.endpoint { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; font-family: var(--mono); font-size: .95rem; margin-bottom: .75rem; }
.method { font-weight: 700; font-size: .75rem; padding: .15rem .5rem; border-radius: 6px; color: #fff; }
.method-get { background: #1f8a5b; }
.method-post { background: #2457d6; }
.callout { border-left: 3px solid var(--primary); background: var(--primary-soft); padding: .8rem 1rem; border-radius: 0 var(--radius) var(--radius) 0; margin-bottom: 1rem; }
.callout.warning { border-color: var(--warning); background: var(--warning-soft); }

@media (max-width: 860px) {
    .docs { grid-template-columns: 1fr; }
    .docs-nav { position: static; max-height: none; display: flex; flex-wrap: wrap; gap: .25rem; }
    .docs-nav .group { width: 100%; margin: .5rem 0 0; }
    dl.details { grid-template-columns: 1fr; gap: .1rem; }
    dl.details dd { margin-bottom: .6rem; }
}
