/* =========================================================
   Simple, centered, mobile‑friendly admin styles
   ========================================================= */

/* Basic reset */
*,
*::before,
*::after {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
}

body {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 16px;
    line-height: 1.5;
    color: #222;
    background-color: #f4f4f6;
    padding: 24px 12px 32px;
}

/* Center all admin pages with a max width */
body.page-admin,
body.admin-console,
body.admin-view-stores,
body.admin-store-edit,
body.admin-view-deals,
body.admin-deals-edit,
body.admin-view-events,
body.admin-events-edit {
    max-width: 960px;
    margin: 0 auto;
}

/* Headings & text */
h1, h2, h3 {
    margin: 0 0 16px;
    font-weight: 600;
    text-align: center;
    color: #111;
}

p {
    margin: 0 0 12px;
}

a {
    color: #1a73e8;
    text-decoration: none;
}

a:hover,
a:focus {
    text-decoration: underline;
}

.muted {
    font-size: 0.85rem;
    color: #777;
}

/* Container helpers (used implicitly via body max-width) */
main,
form {
    width: 100%;
}

/* =========================================================
   Buttons
   ========================================================= */

.btn {
    display: inline-block;
    padding: 0.45rem 0.9rem;
    border-radius: 4px;
    border: 1px solid transparent;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    text-align: center;
    text-decoration: none;
    background-color: #e0e0e0;
    color: #222;
    min-width: 80px;
}

.btn:hover,
.btn:focus {
    filter: brightness(0.96);
}

.btn-primary {
    background-color: #2e7d32;
    border-color: #2e7d32;
    color: #fff;
}

.btn-secondary {
    background-color: #1976d2;
    border-color: #1976d2;
    color: #fff;
}

.btn-delete {
    background-color: #c62828;
    border-color: #c62828;
    color: #fff;
}

.btn-small {
    padding: 0.3rem 0.6rem;
    font-size: 0.85rem;
    min-width: 0;
}

/* Center common button rows */
body.admin-view-stores p a.btn,
body.admin-view-deals p a.btn,
body.admin-view-events p a.btn,
body.admin-store-edit p a.btn,
body.admin-deals-edit p a.btn,
body.admin-events-edit p a.btn,
body.admin-console p a.btn {
    display: inline-block;
}

/* =========================================================
   Forms (edit pages + login)
   ========================================================= */

label {
    display: block;
    margin-bottom: 4px;
    font-weight: 500;
    color: #222;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="date"],
input[type="file"],
select,
textarea {
    width: 100%;
    padding: 0.5rem 0.6rem;
    border-radius: 4px;
    border: 1px solid #ccc;
    font-size: 0.95rem;
    font-family: inherit;
}

textarea {
    resize: vertical;
}

.grid2 {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem 1rem;
    margin-bottom: 0.75rem;
}

.grid2 > div {
    width: 100%;
}

/* Stack inputs on small screens */
@media (max-width: 640px) {
    .grid2 {
        grid-template-columns: 1fr;
    }
}

/* Login card (admin.php) */
.page-admin .admin-container {
    max-width: 420px;
    margin: 0 auto;
}

.page-admin .admin-login-form {
    background: #fff;
    border-radius: 6px;
    padding: 1.75rem 1.5rem 1.5rem;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
}

.page-admin .admin-login-form h2 {
    margin-bottom: 1rem;
}

.page-admin .admin-login-form .form-group {
    margin-bottom: 0.9rem;
}

.page-admin .admin-login-form .error {
    margin-bottom: 0.75rem;
}

/* =========================================================
   Messages
   ========================================================= */

.msg {
    padding: 0.6rem 0.8rem;
    border-radius: 4px;
    margin-bottom: 0.75rem;
    font-size: 0.9rem;
}

.msg-success {
    background-color: #e8f5e9;
    border: 1px solid #81c784;
    color: #256029;
}

.msg-error {
    background-color: #ffebee;
    border: 1px solid #e57373;
    color: #b71c1c;
}

/* =========================================================
   Admin console (admin-page.php)
   ========================================================= */

body.admin-console {
    font-family: inherit;
}

body.admin-console > p {
    text-align: right;
}

.mall-selector {
    text-align: center;
    margin-bottom: 1rem;
}

.mall-selector select {
    max-width: 260px;
    margin: 0.25rem auto 0;
}

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: center;
}

/* =========================================================
   Excel‑style grids for view pages
   (stores, deals, events)
   ========================================================= */

/* Stores list */
.stores-list {
    margin-top: 0.75rem;
    border: 1px solid #dcdcdc;
    border-radius: 4px;
    overflow: hidden;
    background: #fff;
}

/* Header: single full-width cell that says "Store" */
.stores-list-header {
    display: grid;
    grid-template-columns: 1fr;
    align-items: center;
}

.stores-list-header span {
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid #e5e5e5;
    background-color: #ffffff;
    font-weight: 600;
}

/* Data rows: three fixed columns so Edit/Delete cells match in width */
.store-row {
    display: grid;
    grid-template-columns: minmax(0, 2fr) auto auto;
    align-items: center;
}

.store-row > div {
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid #e5e5e5;
    border-right: 1px solid #e5e5e5;
    background-color: #ffffff;
    height: 44px;
    display: flex;
    align-items: center;
    box-sizing: border-box;
}

.store-row > div:last-child {
    border-right: none;
}

.store-block:nth-child(even) .store-row > div {
    background-color: #fafafa;
}

/* Deals & events lists share the same grid look */
.list {
    margin-top: 0.75rem;
    border: 1px solid #dcdcdc;
    border-radius: 4px;
    overflow: hidden;
    background: #fff;
}

.list-header,
.row {
    display: grid;
    grid-template-columns: minmax(0, 2fr) auto auto;
    align-items: center;
}

.list-header span {
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid #e5e5e5;
    border-right: 1px solid #e5e5e5;
    background-color: #ffffff;
}

.row > div {
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid #e5e5e5;
    border-right: 1px solid #e5e5e5;
    background-color: #ffffff;
    height: 44px;
    display: flex;
    align-items: center;
    box-sizing: border-box;
}

.list-header span:last-child,
.row > div:last-child {
    border-right: none;
}

.row-block:nth-child(even) .row > div {
    background-color: #fafafa;
}

/* Make the grids easier to read on small screens:
   stack the action buttons under the title cell */
@media (max-width: 640px) {
    .stores-list-header,
    .store-row,
    .list-header,
    .row {
        grid-template-columns: 1fr;
    }

    .stores-list-header span,
    .list-header span {
        font-weight: 600;
        text-align: left;
    }

    .store-row > div,
    .row > div {
        border-right: none;
    }
}

/* Center the top controls on view pages */
body.admin-view-stores > p,
body.admin-view-deals > p,
body.admin-view-events > p {
    text-align: left;
}

body.admin-view-stores > div:first-of-type,
body.admin-view-deals > div:first-of-type,
body.admin-view-events > div:first-of-type {
    text-align: left;
}

/* =========================================================
   Modals (delete confirmation)
   ========================================================= */

.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    justify-content: center;
    align-items: center;
    padding: 1rem;
    z-index: 1000;
}

.modal-overlay.open {
    display: flex;
}

.modal-dialog {
    background: #fff;
    border-radius: 6px;
    padding: 1rem 1.25rem;
    max-width: 420px;
    width: 100%;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
}

.modal-actions {
    margin-top: 1rem;
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
}

/* =========================================================
   Small tweaks for edit pages
   ========================================================= */

body.admin-store-edit,
body.admin-deals-edit,
body.admin-events-edit {
    font-family: inherit;
}

body.admin-store-edit h1,
body.admin-deals-edit h1,
body.admin-events-edit h1 {
    margin-bottom: 0.75rem;
}

body.admin-store-edit form,
body.admin-deals-edit form,
body.admin-events-edit form {
    background: #fff;
    border-radius: 6px;
    padding: 1rem;
    box-shadow: 0 1px 6px rgba(0, 0, 0, 0.05);
}

