@import url('https://fonts.googleapis.com/css2?family=Lato:ital,wght@0,300;0,400;0,700;0,900;1,400&display=swap');

/* =============================================================================
   UMK Styles — User Management Kit
   Classic CSS, no frameworks.
   Theming via --color-primary / --color-secondary CSS variables,
   injected at runtime by header.php from system_settings.
   ============================================================================= */

/* --- Variables & Reset ------------------------------------------------------ */
:root {
    --color-primary:      #fbd295;
    --color-secondary:    #b07242;
    --color-bg:           #faf7f4;
    --color-surface:      #ffffff;
    --color-border:       #e2e8f0;
    --color-text:         #1e293b;
    --color-text-muted:   #6b5c4e;
    --color-success:      #16a34a;
    --color-success-bg:   #f0fdf4;
    --color-error:        #dc2626;
    --color-error-bg:     #fef2f2;
    --color-warning:      #d97706;
    --color-warning-bg:   #fffbeb;
    --color-info:         #0284c7;
    --color-info-bg:      #f0f9ff;
    --color-danger:       #dc2626;
    --radius:             6px;
    --radius-lg:          10px;
    --shadow-sm:          0 1px 3px rgba(0,0,0,.08);
    --shadow:             0 4px 12px rgba(0,0,0,.10);
    --font:               'Lato', system-ui, sans-serif;
    --transition:         .15s ease;
    --header-height:      56px;
}

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

html { font-size: 16px; scroll-behavior: smooth; }

body {
    font-family:      var(--font);
    background:       var(--color-bg);
    color:            var(--color-text);
    line-height:      1.6;
    min-height:       100vh;
    display:          flex;
    flex-direction:   column;
}

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

img { max-width: 100%; height: auto; display: block; }

h1, h2, h3, h4 { line-height: 1.25; font-weight: 600; }
h1 { font-size: 1.75rem; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.1rem; }

hr { border: none; border-top: 1px solid var(--color-border); margin: 1.5rem 0; }

/* --- Layout ----------------------------------------------------------------- */
.site-header {
    height:          var(--header-height);
    background:      var(--color-primary);
    color:           #1a1a1a;
    position:        sticky;
    top:             0;
    z-index:         100;
    box-shadow:      var(--shadow-sm);
}

.site-header__inner {
    max-width:       1200px;
    margin:          0 auto;
    padding:         0 1.5rem;
    height:          100%;
    display:         flex;
    align-items:     center;
    justify-content: space-between;
}

.site-header__logo {
    font-weight:  700;
    font-size:    1.1rem;
    color:        #1a1a1a;
    letter-spacing: -.01em;
}
.site-header__logo:hover { text-decoration: none; opacity: .9; }

.site-header__nav {
    display:     flex;
    gap:         1.25rem;
    align-items: center;
}
.site-header__nav a {
    color:       rgba(0,0,0,.7);
    font-size:   .9rem;
    font-weight: 500;
    transition:  color var(--transition);
}
.site-header__nav a:hover { color: #000; text-decoration: none; }

.site-main {
    flex:        1;
    max-width:   1200px;
    width:       100%;
    margin:      0 auto;
    padding:     2rem 1.5rem;
}

.site-footer {
    text-align:  center;
    padding:     1rem;
    font-size:   .8rem;
    color:       var(--color-text-muted);
    border-top:  1px solid var(--color-border);
}

/* --- Cards ------------------------------------------------------------------ */
.card {
    background:    var(--color-surface);
    border:        1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding:       1.5rem;
    box-shadow:    var(--shadow-sm);
}

.card--page {
    max-width:  680px;
    margin:     0 auto;
}

/* Linked cards (dashboard) */
a.card {
    display:        block;
    text-align:     center;
    padding:        2rem 1rem;
    color:          var(--color-text);
    transition:     box-shadow var(--transition), transform var(--transition);
    cursor:         pointer;
}
a.card:hover {
    box-shadow:   var(--shadow);
    transform:    translateY(-2px);
    text-decoration: none;
}

.card__icon { font-size: 2rem; margin-bottom: .5rem; }
.card__label { font-weight: 600; font-size: .95rem; }

/* --- Auth page -------------------------------------------------------------- */
body.page-auth .site-main {
    display:         flex;
    align-items:     flex-start;
    justify-content: center;
    padding-top:     3rem;
}

.auth-card {
    background:    var(--color-surface);
    border:        1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding:       2rem 2.25rem;
    width:         100%;
    max-width:     420px;
    box-shadow:    var(--shadow);
}

.auth-card__title {
    text-align:    center;
    margin-bottom: 1.5rem;
    font-size:     1.4rem;
    color:         #1a1a1a;
}

.auth-tabs {
    display:         flex;
    border-bottom:   2px solid var(--color-border);
    margin-bottom:   1.5rem;
}

.auth-tab {
    flex:             1;
    padding:          .55rem 0;
    background:       none;
    border:           none;
    border-bottom:    2px solid transparent;
    margin-bottom:    -2px;
    font-size:        .9rem;
    font-weight:      500;
    cursor:           pointer;
    color:            var(--color-text-muted);
    transition:       color var(--transition), border-color var(--transition);
}
.auth-tab--active {
    color:        #1a1a1a;
    border-color: #1a1a1a;
}

.auth-error {
    background:    var(--color-error-bg);
    color:         var(--color-error);
    border-radius: var(--radius);
    padding:       .5rem .75rem;
    font-size:     .875rem;
    margin-bottom: .75rem;
}

/* --- Forms ------------------------------------------------------------------ */
.auth-form,
.profile-form,
.settings-form,
.setup-form {
    display:        flex;
    flex-direction: column;
    gap:            1rem;
}

.field {
    display:        flex;
    flex-direction: column;
    gap:            .3rem;
}

.field label {
    font-size:   .875rem;
    font-weight: 500;
    color:       var(--color-text);
}

.field input,
.field select,
.field textarea {
    padding:       .55rem .75rem;
    border:        1px solid var(--color-border);
    border-radius: var(--radius);
    font-size:     .95rem;
    font-family:   var(--font);
    color:         var(--color-text);
    background:    var(--color-surface);
    transition:    border-color var(--transition), box-shadow var(--transition);
    width:         100%;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
    outline:      none;
    border-color: var(--color-primary);
    box-shadow:   0 0 0 3px rgba(79,70,229,.15);
}

.field input:disabled,
.field select:disabled {
    background: var(--color-bg);
    color:      var(--color-text-muted);
    cursor:     not-allowed;
}

.field textarea { min-height: 100px; resize: vertical; }

.field--row {
    flex-direction: row;
    align-items:    center;
    justify-content: space-between;
}

.field-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap:     1rem;
}

.hint { font-size: .8rem; color: var(--color-text-muted); font-weight: 400; }

.field-group {
    background:    var(--color-bg);
    border:        1px solid var(--color-border);
    border-radius: var(--radius);
    padding:       1rem;
    display:       flex;
    flex-direction: column;
    gap:           .75rem;
}

.field-group legend,
.field-group-label {
    font-size:   .8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .05em;
    color:       var(--color-text-muted);
    margin-bottom: .25rem;
}

/* Color picker + preview */
.color-picker-row {
    display:     flex;
    align-items: center;
    gap:         .5rem;
}
.color-picker-row input[type="color"] {
    width:  40px;
    height: 38px;
    padding: 2px;
    cursor:  pointer;
}
.color-preview {
    width:         32px;
    height:        32px;
    border-radius: 50%;
    border:        2px solid var(--color-border);
    flex-shrink:   0;
}

/* --- Buttons ---------------------------------------------------------------- */
.btn {
    display:        inline-flex;
    align-items:    center;
    justify-content: center;
    gap:            .4rem;
    padding:        .55rem 1.1rem;
    border:         1px solid transparent;
    border-radius:  var(--radius);
    font-size:      .9rem;
    font-family:    var(--font);
    font-weight:    500;
    cursor:         pointer;
    transition:     background var(--transition), border-color var(--transition), box-shadow var(--transition);
    white-space:    nowrap;
    text-decoration: none;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }

.btn--primary {
    background:   var(--color-primary);
    color:        #1a1a1a;
    border-color: var(--color-primary);
}
.btn--primary:hover { filter: brightness(1.08); }

.btn--secondary {
    background:   var(--color-secondary);
    color:        #fff;
    border-color: var(--color-secondary);
}
.btn--secondary:hover { filter: brightness(1.08); }

.btn--ghost {
    background:   transparent;
    color:        var(--color-text);
    border-color: var(--color-border);
}
.btn--ghost:hover { background: var(--color-bg); }

.btn--danger {
    background:   var(--color-danger);
    color:        #fff;
    border-color: var(--color-danger);
}
.btn--danger:hover { filter: brightness(1.08); }

.btn--success {
    background:   var(--color-success);
    color:        #fff;
    border-color: var(--color-success);
}
.btn--success:hover { filter: brightness(1.08); }

.btn--sm { padding: .3rem .65rem; font-size: .8rem; }
.btn--lg { padding: .75rem 1.5rem; font-size: 1rem; }
.btn--full { width: 100%; }

.btn-row {
    display:   flex;
    gap:       .75rem;
    flex-wrap: wrap;
    align-items: center;
}

/* --- Alerts ----------------------------------------------------------------- */
.alert {
    border-radius: var(--radius);
    padding:       .65rem 1rem;
    font-size:     .9rem;
    border:        1px solid transparent;
    margin-bottom: .5rem;
}

.alert--success {
    background: var(--color-success-bg);
    color:      var(--color-success);
    border-color: #bbf7d0;
}
.alert--error {
    background: var(--color-error-bg);
    color:      var(--color-error);
    border-color: #fecaca;
}
.alert--warning {
    background: var(--color-warning-bg);
    color:      var(--color-warning);
    border-color: #fde68a;
}
.alert--info {
    background: var(--color-info-bg);
    color:      var(--color-info);
    border-color: #bae6fd;
}

/* --- Badges ----------------------------------------------------------------- */
.badge {
    display:       inline-block;
    padding:       .15rem .55rem;
    border-radius: 99px;
    font-size:     .75rem;
    font-weight:   600;
    letter-spacing: .02em;
}

.badge--green   { background: #dcfce7; color: #15803d; }
.badge--red     { background: #fee2e2; color: #b91c1c; }
.badge--blue    { background: #dbeafe; color: #1d4ed8; }
.badge--yellow  { background: #fef9c3; color: #854d0e; }
.badge--purple  { background: #ede9fe; color: #6d28d9; }
.badge--gray    { background: #f1f5f9; color: #475569; }

/* --- Tables ----------------------------------------------------------------- */
.table-wrap { overflow-x: auto; border-radius: var(--radius-lg); border: 1px solid var(--color-border); }

table.datatable,
table.umk-table {
    width:           100%;
    border-collapse: collapse;
    font-size:       .875rem;
}

table.datatable thead th,
table.umk-table thead th {
    background:   var(--color-bg);
    padding:      .65rem 1rem;
    text-align:   left;
    font-weight:  600;
    font-size:    .8rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    color:        var(--color-text-muted);
    border-bottom: 1px solid var(--color-border);
}

table.datatable tbody td,
table.umk-table tbody td {
    padding:      .65rem 1rem;
    border-bottom: 1px solid var(--color-border);
    vertical-align: middle;
}

table.datatable tbody tr:last-child td,
table.umk-table tbody tr:last-child td {
    border-bottom: none;
}

table.datatable tbody tr:hover,
table.umk-table tbody tr:hover {
    background: #f8faff;
}

/* DataTables overrides */
.dataTables_wrapper { padding: 0; }
.dataTables_filter input {
    padding:       .4rem .65rem;
    border:        1px solid var(--color-border);
    border-radius: var(--radius);
    font-size:     .875rem;
}
.dataTables_length select {
    padding:       .3rem .5rem;
    border:        1px solid var(--color-border);
    border-radius: var(--radius);
}
.dataTables_info { font-size: .8rem; color: var(--color-text-muted); }
.paginate_button { padding: .25rem .5rem !important; border-radius: var(--radius) !important; cursor: pointer; }
.paginate_button.current { background: var(--color-primary) !important; color: #1a1a1a !important; border-color: var(--color-primary) !important; }

/* role select inside table */
select.role-sel {
    padding:       .25rem .4rem;
    font-size:     .8rem;
    border:        1px solid var(--color-border);
    border-radius: var(--radius);
}

/* --- Dashboard -------------------------------------------------------------- */
.dashboard { max-width: 900px; }

.dashboard__greeting { margin-bottom: 2rem; }
.dashboard__greeting h1 { font-size: 1.6rem; }

.dashboard__cards {
    display:               grid;
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
    gap:                   1rem;
}

/* --- Admin pages ------------------------------------------------------------ */
.admin-page { max-width: 1100px; }
.admin-page h1 { margin-bottom: 1.5rem; }

.admin-header {
    display:         flex;
    align-items:     center;
    justify-content: space-between;
    margin-bottom:   1.5rem;
    flex-wrap:       wrap;
    gap:             1rem;
}

/* Stat cards in admin dashboard */
.stat-grid {
    display:               grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap:                   1rem;
    margin-bottom:         2rem;
}

.stat-card {
    background:    var(--color-surface);
    border:        1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding:       1.25rem 1.5rem;
    box-shadow:    var(--shadow-sm);
}

.stat-card__value {
    font-size:   2rem;
    font-weight: 700;
    color:       #1a1a1a;
    line-height: 1;
}

.stat-card__label {
    font-size:  .8rem;
    color:      var(--color-text-muted);
    margin-top: .3rem;
    font-weight: 500;
}

.recent-list {
    list-style: none;
}

.recent-list li {
    display:       flex;
    align-items:   center;
    gap:           .75rem;
    padding:       .6rem 0;
    border-bottom: 1px solid var(--color-border);
    font-size:     .9rem;
}

.recent-list li:last-child { border-bottom: none; }

.recent-list .recent-name { font-weight: 500; flex: 1; }
.recent-list .recent-date { color: var(--color-text-muted); font-size: .8rem; }

/* --- Settings page --------------------------------------------------------- */
.settings-page { max-width: 760px; }

.settings-section {
    margin-bottom: 2rem;
}

.settings-section h2 {
    font-size:     1rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    color:          var(--color-text-muted);
    border-bottom:  1px solid var(--color-border);
    padding-bottom: .4rem;
    margin-bottom:  1rem;
}

/* --- Setup wizard ----------------------------------------------------------- */
.setup-wrap {
    max-width:  640px;
    margin:     0 auto;
}

.setup-card {
    background:    var(--color-surface);
    border:        1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding:       2rem 2.25rem;
    box-shadow:    var(--shadow);
}

.setup-card h1 {
    font-size:     1.5rem;
    margin-bottom: .5rem;
}

.setup-card .subtitle {
    color:         var(--color-text-muted);
    margin-bottom: 1.5rem;
    font-size:     .95rem;
}

.setup-steps {
    display:         flex;
    gap:             .25rem;
    margin-bottom:   1.75rem;
    align-items:     center;
}

.setup-step {
    flex:           1;
    height:         4px;
    border-radius:  2px;
    background:     var(--color-border);
    transition:     background var(--transition);
}

.setup-step--done    { background: var(--color-success); }
.setup-step--active  { background: var(--color-primary); }

/* Checklist */
.checklist { list-style: none; display: flex; flex-direction: column; gap: .6rem; }

.checklist li {
    display:    flex;
    gap:        .6rem;
    align-items: flex-start;
    font-size:  .925rem;
}

.checklist li::before {
    content:     '✓';
    color:       var(--color-success);
    font-weight: 700;
    flex-shrink: 0;
    margin-top:  .05rem;
}

/* Deployment log */
.deploy-log {
    background:    #0f172a;
    color:         #94a3b8;
    border-radius: var(--radius);
    padding:       1rem;
    font-family:   'Courier New', monospace;
    font-size:     .8rem;
    max-height:    280px;
    overflow-y:    auto;
    line-height:   1.7;
}

.deploy-log .log-ok    { color: #4ade80; }
.deploy-log .log-error { color: #f87171; }
.deploy-log .log-info  { color: #60a5fa; }

/* Summary table */
.summary-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.summary-table td { padding: .45rem .5rem; border-bottom: 1px solid var(--color-border); }
.summary-table td:first-child { font-weight: 500; width: 40%; color: var(--color-text-muted); }

/* --- Misc ------------------------------------------------------------------- */
.text-muted   { color: var(--color-text-muted); }
.text-center  { text-align: center; }
.link-subtle  { font-size: .875rem; color: var(--color-text-muted); }
.link-subtle:hover { color: var(--color-primary); }
.mt-1  { margin-top: .5rem;  }
.mt-2  { margin-top: 1rem;   }
.mt-3  { margin-top: 1.5rem; }
.mb-1  { margin-bottom: .5rem;  }
.mb-2  { margin-bottom: 1rem;   }

/* --- Responsive ------------------------------------------------------------- */
@media (max-width: 600px) {
    .site-main          { padding: 1.25rem 1rem; }
    .auth-card          { padding: 1.5rem 1.25rem; }
    .setup-card         { padding: 1.5rem 1.25rem; }
    .field-row          { grid-template-columns: 1fr; }
    .dashboard__cards   { grid-template-columns: 1fr 1fr; }
    .stat-grid          { grid-template-columns: 1fr 1fr; }
    .btn-row            { flex-direction: column; }
    .btn--full-mobile   { width: 100%; }
}

/* ── Emulation banner ─────────────────────────────────────────────────────── */
.emulation-banner {
  background: #b45309;
  color: #fff;
  padding: .55rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  font-size: .875rem;
  font-weight: 500;
}
.emulation-banner strong { font-weight: 700; }
.emulation-banner__exit {
  background: rgba(255,255,255,.18);
  color: #fff;
  border: 1px solid rgba(255,255,255,.4);
  border-radius: .35rem;
  padding: .25rem .75rem;
  text-decoration: none;
  white-space: nowrap;
  font-size: .8rem;
}
.emulation-banner__exit:hover { background: rgba(255,255,255,.3); }
