/* NORMA Admin — estetica verde-teal coherente con noratel.cl */

:root {
    --primary: #05BC9D;
    --primary-dark: #038E77;
    --accent: #0891B2;
    --bg: #0A2540;
    --bg-soft: #f7f8fa;
    --surface: #ffffff;
    --text: #0f172a;
    --text-dim: #64748b;
    --border: #e2e8f0;
    --success: #10b981;
    --error: #ef4444;
    --error-bg: #fee2e2;
    --ok-bg: #d1fae5;
    --warn: #f59e0b;
}

* { box-sizing: border-box; }

html, body {
    margin: 0; padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 15px;
    line-height: 1.55;
    color: var(--text);
    background: var(--bg-soft);
}

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

.shell {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

/* ── Auth (login / totp / change-password) ── */

.auth-card {
    background: var(--surface);
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(10, 37, 64, 0.12);
    padding: 40px;
    width: 100%;
    max-width: 440px;
}

.auth-card h1 {
    margin: 20px 0 24px;
    font-size: 1.6rem;
    color: var(--text);
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 24px;
}

.brand-mark {
    width: 44px; height: 44px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: white;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700;
    font-size: 1.4rem;
    letter-spacing: -1px;
}

.brand-logo {
    height: 44px;
    width: auto;
    max-width: 180px;
    display: block;
}

.brand-name {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--text);
}

.brand-sub {
    font-size: 0.85rem;
    color: var(--text-dim);
}

form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 0.9rem;
    color: var(--text-dim);
    font-weight: 500;
}

input[type="text"],
input[type="password"] {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
    color: var(--text);
    background: var(--bg-soft);
    transition: border-color 0.15s, background 0.15s;
}

input[type="text"]:focus,
input[type="password"]:focus {
    outline: none;
    border-color: var(--primary);
    background: var(--surface);
}

.btn-primary {
    padding: 12px 16px;
    border: none;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: white;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: transform 0.1s, box-shadow 0.15s;
    margin-top: 6px;
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(5, 188, 157, 0.3);
}

.btn-primary:active {
    transform: translateY(0);
}

.alert {
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 0.92rem;
    margin-bottom: 16px;
}

.alert-error {
    background: var(--error-bg);
    color: var(--error);
    border: 1px solid #fca5a5;
}

.alert-ok {
    background: var(--ok-bg);
    color: var(--success);
    border: 1px solid #6ee7b7;
}

.hint {
    margin-top: 16px;
    font-size: 0.85rem;
    color: var(--text-dim);
    text-align: center;
}

.totp-setup {
    margin: 16px 0;
    padding: 16px;
    background: #f0f9ff;
    border: 1px solid #bae6fd;
    border-radius: 8px;
    text-align: center;
}

.totp-qr {
    max-width: 200px;
    margin: 12px auto;
    display: block;
    border: 2px solid white;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

/* ── Panel (dashboard) ── */

.shell:has(.panel) {
    align-items: flex-start;
    padding: 0;
}

.panel {
    width: 100%;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--bg-soft);
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 32px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 1px 3px rgba(0,0,0,0.02);
}

.user-chip {
    display: flex;
    align-items: center;
    gap: 16px;
    font-size: 0.92rem;
    color: var(--text);
    font-weight: 500;
}

.logout {
    color: var(--text-dim);
    font-size: 0.88rem;
}

.logout:hover { color: var(--error); }

.panel-main {
    flex: 1;
    padding: 32px;
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
}

.panel-main h1 {
    margin: 0 0 8px;
    font-size: 1.8rem;
}

.module-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 16px;
    margin-top: 24px;
}

.module-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 20px;
    display: flex;
    gap: 16px;
    align-items: flex-start;
    transition: border-color 0.15s, box-shadow 0.15s, transform 0.1s;
    cursor: default;
}

.module-card:hover {
    border-color: var(--primary);
    box-shadow: 0 6px 18px rgba(5, 188, 157, 0.12);
    transform: translateY(-2px);
}

.module-icon {
    font-size: 2rem;
    line-height: 1;
}

.module-name {
    font-weight: 600;
    color: var(--text);
    margin-bottom: 4px;
}

.module-desc {
    font-size: 0.88rem;
    color: var(--text-dim);
    margin-bottom: 10px;
}

.module-status {
    display: inline-block;
    font-size: 0.75rem;
    padding: 2px 8px;
    background: var(--bg-soft);
    color: var(--warn);
    border-radius: 12px;
    border: 1px solid var(--border);
    font-weight: 600;
}

.panel-footer {
    padding: 16px 32px;
    font-size: 0.8rem;
    color: var(--text-dim);
    border-top: 1px solid var(--border);
    background: var(--surface);
    text-align: center;
}

/* ── Modulo Sites / Settings ── */

.module-card-active {
    text-decoration: none;
    color: inherit;
    cursor: pointer;
}

.module-card-disabled {
    opacity: 0.7;
}

.module-card-disabled:hover {
    border-color: var(--border);
    box-shadow: none;
    transform: none;
}

.module-status-ok {
    color: var(--success) !important;
    background: var(--ok-bg) !important;
    border-color: #6ee7b7 !important;
}

.page-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 16px;
    margin-bottom: 20px;
}

.page-actions {
    display: flex;
    gap: 10px;
}

.btn-ghost {
    display: inline-flex;
    align-items: center;
    padding: 10px 16px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.92rem;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

.btn-ghost:hover {
    background: var(--bg-soft);
    border-color: var(--primary);
    text-decoration: none;
}

.btn-danger-sm {
    padding: 6px 12px;
    border: 1px solid #fca5a5;
    border-radius: 6px;
    background: var(--error-bg);
    color: var(--error);
    font-size: 0.85rem;
    cursor: pointer;
    font-weight: 500;
}

.btn-danger-sm:hover {
    background: var(--error);
    color: white;
}

.alert-warn {
    background: #fff3cd;
    color: #664d00;
    border: 1px solid #f0c94a;
}

.empty {
    padding: 40px 20px;
    text-align: center;
    color: var(--text-dim);
    background: var(--surface);
    border: 1px dashed var(--border);
    border-radius: 10px;
}

.table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: var(--surface);
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.table th, .table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    font-size: 0.92rem;
}

.table th {
    background: var(--bg-soft);
    font-weight: 600;
    color: var(--text-dim);
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.table tr:last-child td {
    border-bottom: none;
}

.table tr:hover td {
    background: var(--bg-soft);
}

.chip {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 0.78rem;
    font-weight: 600;
    background: var(--bg-soft);
    border: 1px solid var(--border);
    color: var(--text-dim);
}

.chip-ok { background: var(--ok-bg); color: var(--success); border-color: #6ee7b7; }
.chip-warn { background: #fff3cd; color: #8a5a00; border-color: #f0c94a; }
.chip-danger { background: var(--error-bg); color: var(--error); border-color: #fca5a5; }
.chip-managed { background: #e0f2fe; color: #075985; border-color: #7dd3fc; }
.chip-placeholder { background: var(--bg-soft); }
.chip-noratel { background: #d1fae5; color: #065f46; }
.chip-norma { background: #cffafe; color: #164e63; }

.muted { color: var(--text-dim); font-size: 0.85rem; }

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

/* Form card */

.form-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 24px;
    margin-top: 20px;
    max-width: 720px;
}

.form-row {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 16px;
}

.form-card label {
    margin-top: 14px;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
}

.template-picker {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 10px;
    margin-top: 6px;
}

.tpl-option {
    flex-direction: row !important;
    align-items: flex-start;
    padding: 12px;
    border: 2px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
    background: var(--surface);
    gap: 10px !important;
}

.tpl-option input[type="radio"] {
    margin-top: 3px;
    accent-color: var(--primary);
}

.tpl-option:has(input:checked) {
    border-color: var(--primary);
    background: #f0fdfa;
}

.tpl-option span {
    font-size: 0.9rem;
    color: var(--text);
}

.tpl-option small {
    color: var(--text-dim);
    font-size: 0.78rem;
}

.explain {
    margin-top: 32px;
    padding: 20px;
    background: #f0f9ff;
    border: 1px solid #bae6fd;
    border-radius: 10px;
    max-width: 720px;
}

.explain h3 {
    margin-bottom: 8px;
    color: #075985;
    font-size: 1rem;
}

.explain ol {
    margin-left: 22px;
    font-size: 0.92rem;
    color: var(--text);
}

.explain ol li {
    margin: 4px 0;
}

.explain code {
    background: #dbeafe;
    padding: 1px 6px;
    border-radius: 4px;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.88em;
    color: #1e3a8a;
}

/* ── Files browser ── */

.breadcrumb {
    padding: 10px 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
}

.breadcrumb a {
    color: var(--accent);
    text-decoration: none;
    padding: 2px 6px;
    border-radius: 4px;
}

.breadcrumb a:hover {
    background: var(--bg-soft);
    text-decoration: none;
}

.bc-sep { color: var(--text-dim); }
.bc-current {
    color: var(--text);
    font-weight: 600;
    padding: 2px 6px;
}

.files-toolbar {
    display: flex;
    gap: 16px;
    margin-bottom: 16px;
    flex-wrap: wrap;
    align-items: center;
}

.inline-form {
    display: inline-flex;
    gap: 6px;
    align-items: center;
    margin: 0;
}

.inline-form input[type="text"] {
    padding: 8px 10px;
    max-width: 240px;
    font-size: 0.9rem;
}

.inline-form input[type="file"] {
    font-size: 0.85rem;
    padding: 4px;
    max-width: 260px;
}

.file-view {
    background: #1e293b;
    color: #e2e8f0;
    padding: 20px;
    border-radius: 10px;
    overflow: auto;
    max-height: 70vh;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.88rem;
    line-height: 1.55;
    white-space: pre-wrap;
    word-break: break-all;
}
