/* =====================================================
   Etsa License Server - Admin theme (Persian / RTL)
   ===================================================== */

:root {
    --navy: #12264a;
    --navy-1: #0a192e;
    --navy-2: #101e40;
    --navy-3: #19295c;
    --navy-4: #081b31;
    --accent: #ff7534;
    --accent-dark: #e8641f;
    --bg: #f2f6fb;
    --card-border: #e2eaf5;
    --green: #0e9f6e;
    --red: #e0526e;
    --amber: #d97706;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
    background: var(--bg);
    color: #1f2a44;
    font-family: 'Vazirmatn', 'Tahoma', 'Segoe UI', sans-serif;
    font-size: 14px;
    direction: rtl;
    line-height: 1.7;
}

a { color: #1d4ed8; text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { font-weight: 700; }

/* ---------- layout ---------- */

.app { display: flex; min-height: 100vh; }

.sidebar {
    width: 240px;
    flex-shrink: 0;
    background: linear-gradient(161deg, #0a192e 0%, #101e40 51%, #19295c 76%, #081b31 100%);
    color: #ffffff;
    display: flex;
    flex-direction: column;
    padding: 20px 14px;
}

.brand { padding: 0 8px 14px; }
.brand-title { font-size: 17px; font-weight: 800; line-height: 1.5; }
.brand-sub { font-size: 12px; color: #9fb3d9; margin-top: 4px; }

.nav { margin-top: 14px; display: flex; flex-direction: column; gap: 6px; }

.nav-item {
    display: block;
    color: #cfdcf5;
    padding: 10px 14px;
    border-radius: 999px;
    font-size: 14px;
}
.nav-item:hover { background: rgba(255, 255, 255, 0.08); color: #ffffff; text-decoration: none; }
.nav-item.active { background: var(--accent); color: #ffffff; font-weight: 700; }
.logout-link { color: #ffb694; }

.sidebar-foot { margin-top: auto; border-top: 1px solid rgba(255, 255, 255, 0.12); padding-top: 12px; }
.admin-chip { font-size: 12.5px; color: #9fb3d9; padding: 0 8px 8px; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
    background: #ffffff;
    border-bottom: 1px solid var(--card-border);
    padding: 14px 24px;
}
.page-title { margin: 0; font-size: 19px; color: var(--navy); }

.content { padding: 22px 24px 30px; }

.footer { text-align: center; color: #8a97b5; font-size: 12px; padding: 14px 0 26px; }

/* ---------- cards & stats ---------- */

.card {
    background: #ffffff;
    border: 1px solid var(--card-border);
    border-radius: 14px;
    padding: 18px;
}

.card h2 { color: var(--navy); margin: 0 0 14px; font-size: 16px; }
.card h3 { color: var(--navy); margin: 0 0 10px; font-size: 14.5px; }

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

.stat-value { font-size: 22px; font-weight: 800; color: var(--navy); }
.stat-label { color: #64748b; font-size: 12.5px; margin-top: 4px; }
.stat-green { color: var(--green); }
.stat-red { color: var(--red); }
.stat-amber { color: var(--amber); }

.page-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}
.page-head h2 { margin: 0; color: var(--navy); font-size: 17px; }

/* ---------- tables ---------- */

.table-wrap {
    background: #ffffff;
    border: 1px solid var(--card-border);
    border-radius: 14px;
    overflow: auto;
}

table.data-table { width: 100%; border-collapse: collapse; background: #ffffff; }

.data-table th, .data-table td {
    padding: 10px 12px;
    text-align: right;
    border-bottom: 1px solid #eef2f9;
    vertical-align: middle;
}

.data-table thead th { background: #f6f9fd; color: var(--navy); font-size: 13px; white-space: nowrap; }
.data-table tbody tr:nth-child(even) { background: #fafcff; }
.data-table tbody tr:hover { background: #f1f6ff; }

/* ---------- badges & chips ---------- */

.badge {
    display: inline-block;
    padding: 3px 12px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
}
.badge-green { background: #e7f7f0; color: var(--green); }
.badge-red { background: #fdeaee; color: var(--red); }
.badge-amber { background: #fdf3e3; color: var(--amber); }

.chip {
    display: inline-block;
    padding: 3px 12px;
    border-radius: 8px;
    background: #e8edf9;
    color: var(--navy);
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

/* ---------- buttons ---------- */

.btn {
    display: inline-block;
    border: 0;
    border-radius: 10px;
    padding: 9px 18px;
    font-size: 14px;
    font-family: inherit;
    cursor: pointer;
    line-height: 1.6;
}
.btn:hover { text-decoration: none; }

.btn-primary { background: var(--accent); color: #ffffff; font-weight: 600; }
.btn-primary:hover { background: var(--accent-dark); }

.btn-secondary { background: #ffffff; color: var(--navy); border: 1px solid #cdd9ec; }
.btn-secondary:hover { background: #f4f7fc; }

.btn-danger { background: var(--red); color: #ffffff; }
.btn-danger:hover { background: #c73e59; }

.btn-sm { padding: 5px 12px; font-size: 12.5px; border-radius: 8px; }

/* ---------- forms ---------- */

input[type="text"], input[type="password"], input[type="number"],
input[type="date"], input[type="month"], input[type="email"],
select, textarea {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid #cdd9ec;
    border-radius: 10px;
    font-family: inherit;
    font-size: 14px;
    background: #ffffff;
    color: #1f2a44;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(255, 117, 52, 0.15);
}
textarea { min-height: 80px; resize: vertical; }

.field label { display: block; margin-bottom: 6px; color: var(--navy); font-size: 13px; font-weight: 600; }

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 14px;
}

.form-actions { margin-top: 16px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

.form-section-title { color: var(--navy); font-size: 14px; margin: 18px 0 10px; }

.serial-row { display: flex; gap: 8px; }
.serial-row input { flex: 1; }

.mono {
    font-family: Consolas, 'Courier New', monospace;
    direction: ltr;
    unicode-bidi: isolate;
    letter-spacing: 0.4px;
}

.muted { color: #64748b; font-size: 12.5px; }

.result-count { color: #64748b; font-size: 13px; margin: 0 0 10px; }

.toolbar {
    display: flex;
    gap: 12px;
    align-items: flex-end;
    flex-wrap: wrap;
    background: #ffffff;
    border: 1px solid var(--card-border);
    border-radius: 14px;
    padding: 14px 16px;
    margin-bottom: 16px;
}
.toolbar .field { min-width: 170px; }
.toolbar label { color: #64748b; }

.actions-cell { white-space: nowrap; }
form.inline { display: inline-block; margin: 0; }

/* ---------- flash & alerts ---------- */

.flash { border-radius: 12px; padding: 12px 16px; margin-bottom: 18px; font-weight: 600; }
.flash-success { background: #e7f7f0; color: #0b7a55; border: 1px solid #bfe9d9; }
.flash-error { background: #fdeaee; color: #b03248; border: 1px solid #f6c6d1; }

.alert { border-radius: 12px; padding: 11px 14px; margin-bottom: 14px; font-size: 13.5px; }
.alert-error { background: #fdeaee; color: #b03248; border: 1px solid #f6c6d1; }
.alert-info { background: #e8f1fe; color: #1e4fa3; border: 1px solid #c9dcf8; }
.alert-success { background: #e7f7f0; color: #0b7a55; border: 1px solid #bfe9d9; }

/* ---------- pagination ---------- */

.pagination { display: flex; gap: 8px; margin-top: 16px; flex-wrap: wrap; align-items: center; }
.pagination a, .pagination span {
    padding: 6px 14px;
    background: #ffffff;
    border: 1px solid var(--card-border);
    border-radius: 8px;
    color: var(--navy);
    font-size: 13px;
}
.pagination a:hover { background: #f1f6ff; text-decoration: none; }
.pagination .current { background: var(--accent); color: #ffffff; border-color: var(--accent); font-weight: 600; }

/* ---------- login page ---------- */

.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(161deg, #0a192e 0%, #101e40 51%, #19295c 76%, #081b31 100%);
    padding: 20px;
}

.login-card {
    width: 100%;
    max-width: 400px;
    background: #ffffff;
    border-radius: 18px;
    padding: 30px 26px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
}

.login-brand { text-align: center; color: var(--navy); font-size: 19px; font-weight: 800; margin-bottom: 4px; }
.login-sub { text-align: center; color: #64748b; font-size: 13px; margin-bottom: 16px; }
.login-accent { width: 56px; height: 5px; background: var(--accent); border-radius: 999px; margin: 0 auto 18px; }
.login-btn { width: 100%; }

/* ---------- installer ---------- */

.install-wrap { max-width: 780px; margin: 34px auto 60px; padding: 0 16px; }
.install-card { margin-bottom: 18px; }

.install-step {
    display: inline-block;
    background: var(--accent);
    color: #ffffff;
    border-radius: 999px;
    padding: 3px 14px;
    font-size: 12px;
    font-weight: 700;
    margin-left: 8px;
}

.req-list { list-style: none; padding: 0; margin: 0; }
.req-list li { padding: 9px 0; border-bottom: 1px dashed #e2eaf5; display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.req-ok { color: var(--green); font-weight: 700; }
.req-bad { color: var(--red); font-weight: 700; }

.code-box {
    background: #0f1e3d;
    color: #d7e4ff;
    border-radius: 10px;
    padding: 12px 14px;
    direction: ltr;
    text-align: left;
    font-family: Consolas, 'Courier New', monospace;
    font-size: 12.5px;
    overflow: auto;
    white-space: pre-wrap;
    word-break: break-all;
}

.warn-box {
    background: #fdeaee;
    border: 1px solid #f6c6d1;
    color: #b03248;
    border-radius: 12px;
    padding: 13px 16px;
    margin-top: 16px;
    font-weight: 700;
}

/* ---------- responsive ---------- */

@media (max-width: 900px) {
    .app { flex-direction: column; }
    .sidebar { width: 100%; flex-direction: row; align-items: center; flex-wrap: wrap; gap: 10px; padding: 12px; }
    .brand { padding: 0; }
    .brand-sub { display: none; }
    .nav { margin-top: 0; flex-direction: row; flex-wrap: wrap; }
    .nav-item { padding: 7px 12px; }
    .sidebar-foot { margin-top: 0; border-top: 0; padding-top: 0; margin-right: auto; display: flex; align-items: center; gap: 10px; }
    .admin-chip { padding: 0; }
    .content { padding: 16px 14px 24px; }
    .topbar { padding: 12px 16px; }
    .cards-grid { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
}
