/* ---------------------------------------------------------------------
   Codemola Retail — app.css

   Aesthetic direction: refined utility. Used by cashiers ringing 8-hour
   shifts and shop owners reviewing books at 11pm. Cannot be flashy.
   Must be calm, dense, fast, scannable.

   Choices:
     - Warm off-white (#faf8f3) instead of stark white. Easier on tired
       eyes than #fff. Inspired by paper, not screens.
     - One confident accent: a deep teal (#0e7c7b). NOT purple, NOT
       indigo. Reads as professional without being banking-app generic.
     - Typography: ui-serif for headings (gives just enough personality
       without web-font cost on shared hosting), system-ui for body.
       No web fonts loaded — every request matters on cPanel.
     - Borders, not shadows. Sharp 1px lines feel honest; soft shadows
       fight the calm aesthetic.
     - Generous line-height (1.55) for body, tight (1.2) for headings.
       Numbers tabular for money columns.

   Not a CSS framework. Not Tailwind. Hand-written so we control every
   selector. ~12KB uncompressed.
--------------------------------------------------------------------- */

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

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

body {
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
    font-size: 15px;
    line-height: 1.55;
    color: #1d1c1a;
    background: #faf8f3;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4 {
    font-family: ui-serif, Georgia, "Times New Roman", serif;
    font-weight: 600;
    letter-spacing: -0.01em;
    color: #1d1c1a;
    margin: 0 0 0.5em;
    line-height: 1.2;
}
h1 { font-size: 1.65rem; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.05rem; }

p, ul, ol { margin: 0 0 1em; }
a { color: #0e7c7b; text-decoration: none; }
a:hover { text-decoration: underline; }

code {
    font-family: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;
    font-size: 0.85em;
    background: rgba(14, 124, 123, 0.08);
    color: #075150;
    padding: 1px 6px;
    border-radius: 3px;
}

small { font-size: 0.85em; color: #6b6864; }

.muted { color: #6b6864; }

/* ----- Layout ----- */
.topbar {
    display: flex;
    align-items: center;
    gap: 24px;
    padding: 16px 32px;
    background: #fff;
    border-bottom: 1px solid #e6e1d6;
}
.topbar-brand {
    font-family: ui-serif, Georgia, serif;
    font-size: 1.1rem;
    font-weight: 600;
    color: #1d1c1a;
    letter-spacing: -0.01em;
}
.topbar-brand:hover { text-decoration: none; }
.topbar-nav {
    display: flex;
    gap: 20px;
    margin-left: 16px;
}
.topbar-nav a {
    color: #4b4843;
    font-size: 0.92rem;
    font-weight: 500;
    padding: 4px 0;
    border-bottom: 2px solid transparent;
    transition: border-color 0.15s;
}
.topbar-nav a:hover {
    text-decoration: none;
    border-bottom-color: #0e7c7b;
}
.topbar-user {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.9rem;
}
.user-name {
    color: #4b4843;
    font-weight: 500;
}

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

.footer {
    text-align: center;
    padding: 16px;
    color: #9c9890;
    border-top: 1px solid #e6e1d6;
    background: #fff;
}

/* ----- Page header ----- */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 16px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}
.page-header h1 { margin-bottom: 4px; }
.page-header p  { margin-bottom: 0; }

/* ----- Cards ----- */
.card {
    background: #fff;
    border: 1px solid #e6e1d6;
    border-radius: 6px;
    padding: 20px 24px;
    margin-bottom: 16px;
}
.card h2 { margin-top: 0; }

.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: #6b6864;
}
.empty-state h2 { color: #1d1c1a; }

/* ----- Forms ----- */
form label {
    display: block;
    margin-bottom: 14px;
    font-size: 0.85rem;
    font-weight: 600;
    color: #4b4843;
    letter-spacing: 0.01em;
    text-transform: uppercase;
}
form label input,
form label select,
form label textarea {
    display: block;
    margin-top: 6px;
    width: 100%;
    padding: 10px 12px;
    font-family: inherit;
    font-size: 15px;
    font-weight: 400;
    text-transform: none;
    letter-spacing: 0;
    color: #1d1c1a;
    background: #fff;
    border: 1px solid #d4cdbf;
    border-radius: 4px;
    transition: border-color 0.15s, box-shadow 0.15s;
}
form label input:focus,
form label select:focus,
form label textarea:focus {
    outline: none;
    border-color: #0e7c7b;
    box-shadow: 0 0 0 3px rgba(14, 124, 123, 0.12);
}
form label small {
    display: block;
    margin-top: 4px;
    text-transform: none;
    letter-spacing: 0;
    font-weight: 400;
}

.form-grid {
    display: flex;
    flex-direction: column;
    gap: 20px;
}
.form-section {
    background: #fff;
    border: 1px solid #e6e1d6;
    border-radius: 6px;
    padding: 20px 24px;
}
.form-section h3 {
    margin-top: 0;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid #f0ece2;
}

.form-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-top: 8px;
}
.form-actions-sticky {
    position: sticky;
    bottom: 0;
    background: #faf8f3;
    padding: 16px 0;
    margin-top: 16px;
    border-top: 1px solid #e6e1d6;
}

.checkbox-label {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    text-transform: none;
    letter-spacing: 0;
    font-weight: 400;
    color: #1d1c1a;
    padding: 8px 0;
    cursor: pointer;
}
.checkbox-label input[type="checkbox"] {
    margin-top: 3px;
    width: 16px;
    height: 16px;
    accent-color: #0e7c7b;
    cursor: pointer;
}
.checkbox-label > span {
    display: block;
    line-height: 1.4;
}
.checkbox-label strong {
    font-weight: 600;
    color: #1d1c1a;
}
.checkbox-label small {
    display: block;
    margin-top: 2px;
    font-size: 0.82rem;
    color: #6b6864;
}
.checkbox-label code {
    margin-left: 6px;
    font-size: 0.78rem;
    background: transparent;
    color: #9c9890;
    padding: 0;
}

.checkbox-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 4px 24px;
}

.filter-bar {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    align-items: center;
}
.filter-bar input {
    flex: 1;
    max-width: 320px;
    padding: 8px 12px;
    border: 1px solid #d4cdbf;
    border-radius: 4px;
    font-size: 14px;
    background: #fff;
}
.filter-bar input:focus {
    outline: none;
    border-color: #0e7c7b;
    box-shadow: 0 0 0 3px rgba(14, 124, 123, 0.12);
}

/* ----- Buttons ----- */
.btn-primary, .btn-ghost, .btn-link {
    display: inline-block;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 500;
    padding: 8px 16px;
    border-radius: 4px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
    text-decoration: none;
    line-height: 1.4;
}
.btn-primary {
    background: #0e7c7b;
    color: #fff;
    border-color: #0e7c7b;
}
.btn-primary:hover {
    background: #075150;
    border-color: #075150;
    text-decoration: none;
}
.btn-ghost {
    background: #fff;
    color: #1d1c1a;
    border-color: #d4cdbf;
}
.btn-ghost:hover {
    background: #f5f1e8;
    border-color: #b8b1a2;
    text-decoration: none;
}
.btn-link {
    background: transparent;
    color: #0e7c7b;
    padding: 8px 4px;
    border: 0;
}
.btn-link:hover { text-decoration: underline; }
.btn-link-danger { color: #b91c1c; }
.btn-link-danger:hover { color: #7f1d1d; }

/* ----- Tables ----- */
.data-table {
    width: 100%;
    background: #fff;
    border: 1px solid #e6e1d6;
    border-radius: 6px;
    border-collapse: separate;
    border-spacing: 0;
    overflow: hidden;
    font-size: 14px;
}
.data-table th,
.data-table td {
    text-align: left;
    padding: 10px 16px;
    border-bottom: 1px solid #f0ece2;
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table th {
    background: #f7f3ea;
    color: #4b4843;
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.data-table tbody tr:hover {
    background: #fdfbf5;
}
.cell-actions { text-align: right; white-space: nowrap; }

/* ----- Badges ----- */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 100px;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-left: 6px;
}
.badge-green { background: #dcfce7; color: #166534; }
.badge-grey  { background: #e7e5e0; color: #4b4843; }
.badge-amber { background: #fef3c7; color: #92400e; }
.badge-blue  { background: #dbeafe; color: #1e3a8a; }

/* ----- Alerts ----- */
.alert {
    padding: 12px 16px;
    margin-bottom: 16px;
    border-radius: 4px;
    border-left: 3px solid;
    font-size: 14px;
}
.alert-error   { background: #fef2f2; border-left-color: #b91c1c; color: #7f1d1d; }
.alert-success { background: #ecfdf5; border-left-color: #047857; color: #064e3b; }
.alert-info    { background: #eff6ff; border-left-color: #1e40af; color: #1e3a8a; }

/* ----- Pagination ----- */
.pagination {
    display: flex;
    gap: 4px;
    margin-top: 20px;
    flex-wrap: wrap;
}
.pagination a {
    display: inline-block;
    padding: 6px 12px;
    border: 1px solid #d4cdbf;
    border-radius: 4px;
    color: #4b4843;
    background: #fff;
    font-size: 0.88rem;
}
.pagination a:hover {
    background: #f5f1e8;
    text-decoration: none;
}
.pagination a.is-current {
    background: #0e7c7b;
    border-color: #0e7c7b;
    color: #fff;
}

/* ----- Stats cards ----- */
.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
    margin-bottom: 24px;
}
.stat-card {
    background: #fff;
    border: 1px solid #e6e1d6;
    border-radius: 6px;
    padding: 16px 20px;
}
.stat-num {
    font-family: ui-serif, Georgia, serif;
    font-size: 1.8rem;
    font-weight: 600;
    color: #0e7c7b;
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
}
.stat-label {
    font-size: 0.78rem;
    color: #6b6864;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 4px;
}

/* ----- Permission editor groups ----- */
.permission-group {
    background: #fff;
    border: 1px solid #e6e1d6;
    border-radius: 6px;
    margin-bottom: 16px;
    padding: 16px 20px;
}
.permission-group-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 12px;
    border-bottom: 1px solid #f0ece2;
    margin-bottom: 12px;
}
.permission-group-header h3 { margin: 0; }
.permission-group-actions {
    display: flex;
    gap: 4px;
}
.permission-group-actions .btn-link {
    font-size: 0.78rem;
    padding: 4px 8px;
}

/* ----- Auth card ----- */
.auth-card {
    max-width: 420px;
    margin: 64px auto;
    padding: 32px;
    background: #fff;
    border: 1px solid #e6e1d6;
    border-radius: 8px;
}
.auth-card h1 {
    margin-top: 0;
    margin-bottom: 4px;
}

/* ----- Permission slug list (owner dashboard) ----- */
.perm-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.perm-list code {
    font-size: 0.78rem;
    padding: 3px 8px;
    background: #f0ece2;
    color: #4b4843;
}

/* ----- Error pages ----- */
.error-page {
    max-width: 560px;
    text-align: center;
    padding-top: 80px;
}
.error-num {
    font-family: ui-serif, Georgia, serif;
    font-size: 5rem;
    font-weight: 600;
    color: #0e7c7b;
    line-height: 1;
    margin-bottom: 8px;
}
.error-page h1 {
    margin-bottom: 12px;
}
.error-page .btn-primary {
    margin-top: 20px;
}

/* ----- Responsive ----- */
@media (max-width: 700px) {
    .container { padding: 20px 16px; }
    .topbar { padding: 12px 16px; flex-wrap: wrap; }
    .topbar-nav { width: 100%; order: 3; overflow-x: auto; padding-bottom: 4px; }
    .topbar-user { margin-left: auto; }
    .data-table { font-size: 13px; }
    .data-table th, .data-table td { padding: 8px 10px; }
    .cell-actions { display: flex; flex-wrap: wrap; gap: 4px; }
}
