/* ─────────────────────────────────────────────────────────────────────────────
   Base resets & typography
───────────────────────────────────────────────────────────────────────────── */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    color: #333;
    background: #f5f7fa;
}

body {
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* ─────────────────────────────────────────────────────────────────────────────
   Header & nav
───────────────────────────────────────────────────────────────────────────── */
.header {
    width: 100%;
    background: #fff;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header nav {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1rem;
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    justify-content: center;
    align-items: center;
}

.header a,
.header button {
    color: #4a90e2;
    font-size: 16px;
    font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    text-decoration: none;
    font-weight: 500;
    background: none;
    border: none;
    cursor: pointer;
    transition: color .2s ease;
}

.header a:hover,
.header button:hover {
    color: #357ab8;
}

.header hr {
    border: none;
    border-bottom: 1px solid #e0e0e0;
}

/* ─────────────────────────────────────────────────────────────────────────────
   Container
───────────────────────────────────────────────────────────────────────────── */
.container {
    max-width: 1400px;
    width: 100%;
    padding: 2rem 1rem;
    margin: 1rem auto;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
}

/* ─────────────────────────────────────────────────────────────────────────────
   Forms & inputs
───────────────────────────────────────────────────────────────────────────── */
#login-form {
    margin-bottom: 1.5rem;
}

#login-form label {
    display: block;
    margin-bottom: .5rem;
    font-weight: 500;
}

input[type="text"],
input[type="password"],
select {
    width: 100%;
    padding: .6rem .8rem;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 1rem;
    transition: border-color .2s ease, box-shadow .2s ease;
}

input:focus,
select:focus {
    border-color: #4a90e2;
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.2);
    outline: none;
}

/* ─────────────────────────────────────────────────────────────────────────────
   Buttons: login/search/save + generic
───────────────────────────────────────────────────────────────────────────── */
#login-button,
#search-button,
#save-button {
    display: inline-block;
    padding: .65rem 1.2rem;
    background: #4a90e2;
    color: #fff;
    font-size: 1rem;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: background .2s ease, transform .1s ease, box-shadow .2s ease;
}

#login-button:hover,
#search-button:hover,
#save-button:hover {
    background: #357ab8;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.12);
}

#login-button:active,
#search-button:active,
#save-button:active {
    transform: scale(0.98);
}

/* Base button style for account toggles and other pills */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: .55rem 1.3rem;
    border-radius: 999px;
    font-size: .95rem;
    font-weight: 500;
    border: 1px solid transparent;
    cursor: pointer;
    transition:
        background .2s ease,
        color .2s ease,
        border-color .2s ease,
        box-shadow .2s ease,
        transform .1s ease;
}

/* Primary pill button (used for active choice) */
.btn-primary {
    background: #4a90e2;
    color: #fff;
    border-color: #4a90e2;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

.btn-primary:hover {
    background: #357ab8;
    border-color: #357ab8;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
    transform: translateY(-1px);
}

/* Ghost / secondary button */
.btn-ghost {
    background: #fff;
    color: #4a90e2;
    border-color: #d2d8e4;
}

.btn-ghost:hover {
    background: #f5f7fb;
    border-color: #b6bfd5;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
    transform: translateY(-1px);
}

/* ─────────────────────────────────────────────────────────────────────────────
   Flash messages
───────────────────────────────────────────────────────────────────────────── */
.flash-error {
    margin: .5rem 0 1rem;
    padding: .75rem 1rem;
    background: #fdecea;
    color: #b71c1c;
    border: 1px solid #f5c6cb;
    border-radius: 6px;
}

/* ─────────────────────────────────────────────────────────────────────────────
   Page titles
───────────────────────────────────────────────────────────────────────────── */
h1 {
    margin: 2rem 0 1rem;
    text-align: center;
    font-size: 1.75rem;
}

h2 {
    margin-top: 40px;
}

/* ─────────────────────────────────────────────────────────────────────────────
   Tables (global)
───────────────────────────────────────────────────────────────────────────── */
table {
    width: 90%;
    border-collapse: collapse;
    margin-bottom: 1rem;
}

thead {
    background: #f0f4f8;
}

th,
td {
    padding: .75rem 1rem;
    text-align: left;
    border-bottom: 1px solid #e0e0e0;
}

tbody tr:hover {
    background: rgba(74, 144, 226, 0.05);
    transition: background .2s ease;
}

tbody img {
    border-radius: 4px;
}

/* Generic select width cap */
select {
    max-width: 150px;
}

/* ─────────────────────────────────────────────────────────────────────────────
   Pagination
───────────────────────────────────────────────────────────────────────────── */
.pagination {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    margin-top: 1rem;
    margin-bottom: 50px;
}

.pagination a {
    color: #4a90e2;
    text-decoration: none;
    font-weight: 500;
    transition: color .2s ease;
}

.pagination a:hover {
    color: #357ab8;
}

/* Highlight current page in pagination */
.pagination .current {
    font-weight: 600;
    padding: .25rem .55rem;
    border-radius: 999px;
    background: #e5edf9;
    color: #1f4f96;
}

/* ─────────────────────────────────────────────────────────────────────────────
   Account page layout
───────────────────────────────────────────────────────────────────────────── */
.account-page {
    margin-top: 1.5rem;
}

/* Header area above cards */
.account-header {
    display: flex;
    flex-direction: column;
    gap: .35rem;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid #e4e7ed;
    padding-bottom: 1rem;
}

.account-username {
    font-size: .95rem;
    color: #666;
}

/* Card-like sections */
.account-section {
    margin-top: 1rem;
    padding: 1.25rem 1.5rem;
    border-radius: 10px;
    border: 1px solid #e4e7ed;
    background: #fafbff;
}

.account-section+.account-section {
    margin-top: 1.25rem;
}

.account-section-header h2 {
    margin-top: 0;
    font-size: 1.15rem;
}

.section-description {
    margin-top: .25rem;
    font-size: .9rem;
    color: #6b7280;
}

/* Form layout */
.account-form {
    margin-top: .75rem;
}

.account-form .form-row {
    margin-bottom: .85rem;
    max-width: 420px;
}

.account-form .form-row label {
    display: block;
    margin-bottom: .35rem;
    font-weight: 500;
    font-size: .95rem;
}

.account-form .form-row input[type="password"] {
    width: 100%;
}

/* Align save button to the right */
.account-form .form-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: .75rem;
}

/* Display mode section */
.account-display-mode {
    background: #ffffff;
}

.display-mode-actions {
    display: flex;
    flex-wrap: wrap;
    gap: .75rem;
    margin-top: .75rem;
}

/* Explanatory hint text */
.hint-text {
    margin-top: .75rem;
    font-size: .85rem;
    color: #6b7280;
}

/* ─────────────────────────────────────────────────────────────────────────────
   Danger Zone styling for Default Image Display section
───────────────────────────────────────────────────────────────────────────── */
.account-section.danger-zone {
    border: 1px solid #f5c6cb;
    background: #fff7f7;
    border-left: 5px solid #d9534f;
    padding: 1.5rem 1.5rem 1.75rem;
    box-shadow: 0 2px 10px rgba(217, 83, 79, 0.08);
    position: relative;
    overflow: hidden;
}

/* Decorative gradient flare */
.account-section.danger-zone::before {
    content: "";
    position: absolute;
    top: 0;
    right: -40px;
    width: 180px;
    height: 100%;
    pointer-events: none;
}

/* Danger Zone heading */
.account-section.danger-zone .account-section-header h2 {
    color: #b71c1c;
    font-weight: 600;
    letter-spacing: .5px;
}

/* Subtext */
.account-section.danger-zone .section-description {
    color: #a94442;
}

/* Buttons inside danger zone — more aggressive style */
.danger-zone .btn {
    border-radius: 6px;
    font-weight: 600;
    padding: .7rem 1.35rem;
}

/* Danger primary button */
.danger-zone .btn-primary {
    background: #d9534f;
    border-color: #d9534f;
    color: white;
    box-shadow: 0 2px 6px rgba(217, 83, 79, 0.25);
}

.danger-zone .btn-primary:hover {
    background: #c9302c;
    border-color: #c9302c;
    box-shadow: 0 3px 12px rgba(217, 83, 79, 0.35);
}

/* “Safe option” secondary button */
.danger-zone .btn-ghost {
    color: #d9534f;
    border-color: #f2b3b3;
}

.danger-zone .btn-ghost:hover {
    background: #ffecec;
    border-color: #e79a9a;
}

/* Hint text in danger zone */
.danger-zone .hint-text {
    color: #a94442;
    background: #fff2f2;
    padding: .65rem 1rem;
    border-radius: 6px;
    border: 1px solid #ecc8c8;
    margin-top: 1rem;
}

/* ─────────────────────────────────────────────────────────────────────────────
   Dashboard layout
───────────────────────────────────────────────────────────────────────────── */
.dashboard-page {
    margin-top: 1.5rem;
}

.dashboard-header {
    display: flex;
    flex-direction: column;
    gap: .25rem;
    margin-bottom: 1.25rem;
}

.dashboard-subtitle {
    font-size: .95rem;
    color: #6b7280;
}

/* Toolbar: search (left, full width) + filters (right) */
.dashboard-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: .75rem 1rem;
    margin-bottom: 1.5rem;
}

/* Group: search input + button */
.search-group {
    display: flex;
    flex: 1 1 0;
    flex-wrap: nowrap;
    gap: .4rem;
    align-items: center;
}

/* Search input: full-width, styled */
#search {
    flex: 1 1 auto;
    min-width: 0;

    padding: .65rem .9rem;
    font-size: 1rem;

    border: 1px solid #cbd5e1;
    border-radius: 8px;

    background: #fff;
    color: #334155;

    transition:
        border-color .2s ease,
        box-shadow .2s ease,
        background-color .2s ease;
}

/* Hover effect – subtle lift */
#search:hover {
    border-color: #b6c2d4;
    background-color: #fafbfd;
}

/* Focused – blue focus ring */
#search:focus {
    border-color: #4a90e2;
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.25);
    outline: none;
    background: #fff;
}

/* Filter group (status) pinned to the right */
.filter-group {
    display: flex;
    flex-direction: column;
    gap: .25rem;
    font-size: .9rem;
}

.filter-group label {
    font-weight: 500;
    color: #4b5563;
}

/* Make selects look consistent with inputs */
.filter-group select {
    min-width: 160px;
}

/* Dashboard table full width inside container */
.dashboard-page table {
    width: 100%;
}

/* ─────────────────────────────────────────────────────────────────────────────
   Responsive tweaks
───────────────────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
    .container {
        padding: 1.5rem .75rem;
    }

    /* Dashboard toolbar stacks vertically on tablet/small screens */
    .dashboard-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .search-group {
        width: 100%;
    }

    .search-group #search {
        flex: 1 1 auto;
        width: 100%;
    }

    .filter-group {
        flex-direction: row;
        align-items: center;
        justify-content: flex-start;
        gap: .5rem;
    }
}

@media (max-width: 600px) {

    /* Stack nav items */
    .header nav {
        flex-direction: column;
        gap: .25rem;
    }

    /* Table → cards */
    table,
    thead,
    tbody,
    th,
    td,
    tr {
        display: block;
        width: 100%;
    }

    thead tr {
        display: none;
    }

    tbody tr {
        margin-bottom: 1rem;
        border: 1px solid #e0e0e0;
        border-radius: 6px;
        overflow: hidden;
    }

    tbody td {
        display: flex;
        justify-content: space-between;
        padding: .6rem 1rem;
        position: relative;
    }

    tbody td::before {
        content: attr(data-label);
        font-weight: 500;
        flex: 1 1 40%;
    }

    tbody td:last-child {
        justify-content: flex-start;
        gap: .5rem;
    }

    /* Account cards tighter on mobile */
    .account-section {
        padding: 1rem 1rem;
    }

    .account-form .form-actions {
        justify-content: stretch;
    }

    .account-form .form-actions #save-button {
        width: 100%;
    }

    .display-mode-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .display-mode-actions .btn {
        width: 100%;
    }

    .account-section.danger-zone {
        padding: 1.25rem 1rem;
    }

    /* Dashboard filters stack nicely */
    .filter-group {
        flex-direction: column;
        align-items: flex-start;
    }
}

@media (max-width: 400px) {

    button,
    input[type="submit"] {
        width: 100%;
        text-align: center;
    }
}