/* ================================================================
   FOUNDENZA CMS - ADMIN STYLESHEET
   Upload as: /public_html/admin/assets/css/style.css
   ================================================================ */

:root {
    --primary: #0B1F3A;
    --secondary: #2563EB;
    --accent: #1D4ED8;
    --dark: #111827;
    --white: #FFFFFF;
    --background: #F8FAFC;
    --surface: #F1F5F9;
    --text: #334155;
    --muted: #64748B;
    --border: #E2E8F0;
    --success: #22C55E;
    --warning: #F59E0B;
    --error: #EF4444;
    --sidebar-width: 240px;
    --header-height: 70px;
    --radius: 12px;
    --shadow: 0 10px 30px rgba(15, 23, 42, .08);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    min-height: 100vh;
    font-family: Inter, Arial, sans-serif;
    background: var(--background);
    color: var(--text);
    line-height: 1.5;
}

a {
    color: inherit;
    text-decoration: none;
}

button,
input,
select,
textarea {
    font: inherit;
}

button,
a {
    -webkit-tap-highlight-color: transparent;
}

/* ============================== HEADER ============================== */

.admin-header {
    position: sticky;
    top: 0;
    z-index: 50;
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 0 30px;
    background: var(--primary);
    color: var(--white);
    box-shadow: 0 4px 18px rgba(11, 31, 58, .15);
}

.admin-brand h2 {
    font-size: 24px;
    line-height: 1.1;
    letter-spacing: 1px;
}

.admin-brand span {
    display: block;
    margin-top: 3px;
    font-size: 12px;
    opacity: .78;
}

.admin-user {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 9px 16px;
    border-radius: 999px;
    background: rgba(255, 255, 255, .1);
    font-size: 14px;
}

.admin-user a {
    color: #BFDBFE;
    font-weight: 700;
}

.admin-user a:hover {
    color: var(--white);
}

/* ============================== LAYOUT ============================== */

.admin-layout {
    min-height: calc(100vh - var(--header-height));
}

.admin-sidebar {
    position: fixed;
    top: var(--header-height);
    bottom: 0;
    left: 0;
    z-index: 40;
    width: var(--sidebar-width);
    overflow-y: auto;
    padding: 24px 14px 40px;
    background: var(--white);
    border-right: 1px solid var(--border);
}

.admin-sidebar ul {
    list-style: none;
}

.admin-sidebar li {
    margin-bottom: 6px;
}

.admin-sidebar a {
    display: block;
    padding: 11px 14px;
    border-radius: 8px;
    color: var(--text);
    font-weight: 600;
    transition: background-color .2s ease, color .2s ease;
}

.admin-sidebar a:hover,
.admin-sidebar a:focus-visible {
    background: #EFF6FF;
    color: var(--secondary);
    outline: none;
}

.menu-title {
    margin: 22px 0 9px;
    padding-left: 14px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: .07em;
    text-transform: uppercase;
}

.admin-content {
    min-height: calc(100vh - var(--header-height));
    margin-left: var(--sidebar-width);
    padding: 34px;
}

.admin-content > h1,
.page-heading h1 {
    color: var(--primary);
    font-size: clamp(26px, 3vw, 34px);
    line-height: 1.2;
}

.admin-content > p,
.page-heading p {
    margin-top: 7px;
    color: var(--muted);
}

.admin-content > p {
    margin-bottom: 28px;
}

.page-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 26px;
}

.admin-container,
.cms-container {
    width: 100%;
    max-width: 1280px;
    margin: 0 auto;
}

/* ============================== DASHBOARD ============================== */

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.dashboard-card,
.quick-actions,
.cms-card,
.card,
.seo-card,
.publish-card,
.form-section {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: 0 2px 5px rgba(15, 23, 42, .02);
}

.dashboard-card {
    padding: 24px;
    transition: transform .2s ease, box-shadow .2s ease;
}

.dashboard-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow);
}

.dashboard-card h2,
.dashboard-card h3 {
    margin-bottom: 12px;
    color: var(--muted);
    font-size: 14px;
}

.dashboard-card strong {
    display: block;
    color: var(--primary);
    font-size: 34px;
}

.dashboard-card > p {
    margin-top: 8px;
    color: var(--muted);
    font-size: 13px;
}

.dashboard-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 18px;
}

.dashboard-card-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border-radius: 11px;
    background: #EFF6FF;
    color: var(--secondary);
    font-size: 20px;
    font-weight: 800;
}

.dashboard-card-label {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.quick-actions {
    margin-bottom: 30px;
    padding: 24px;
}

.quick-actions h2 {
    margin-bottom: 18px;
    color: var(--primary);
    font-size: 21px;
}

.quick-actions .btn-primary {
    margin: 5px 8px 5px 0;
}

.quick-action-list {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.quick-action-list .btn-primary,
.quick-action-list .btn-secondary {
    margin: 0;
}

.dashboard-table-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 24px;
}

.dashboard-panel {
    min-width: 0;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--white);
}

.dashboard-section-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 20px 22px;
}

.quick-actions .dashboard-section-heading {
    padding: 0;
    margin-bottom: 18px;
}

.dashboard-section-heading h2,
.quick-actions .dashboard-section-heading h2 {
    margin: 0;
    color: var(--primary);
    font-size: 20px;
}

.dashboard-section-heading p {
    margin-top: 4px;
    color: var(--muted);
    font-size: 13px;
}

.dashboard-section-heading > a,
.dashboard-edit-link {
    flex: 0 0 auto;
    color: var(--secondary);
    font-size: 13px;
    font-weight: 750;
}

.dashboard-table-scroll {
    overflow-x: auto;
}

.dashboard-table {
    min-width: 590px;
}

.dashboard-table th {
    padding: 11px 14px;
    font-size: 12px;
}

.dashboard-table td {
    padding: 12px 14px;
    font-size: 13px;
}

.dashboard-table td strong {
    display: block;
    max-width: 240px;
    overflow: hidden;
    color: var(--primary);
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ============================== FORMS ============================== */

.admin-form {
    width: 100%;
    max-width: 1100px;
}

.form-section,
.cms-card,
.card,
.seo-card,
.publish-card {
    margin-bottom: 24px;
    padding: 25px;
}

.form-section h2,
.cms-card h2,
.card h2,
.seo-card h2,
.publish-card h2 {
    margin-bottom: 22px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
    color: var(--primary);
    font-size: 20px;
}

.form-group {
    margin-bottom: 20px;
}

label,
.form-label {
    display: block;
    margin: 0 0 8px;
    color: var(--dark);
    font-weight: 650;
}

input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]),
select,
textarea,
.form-control {
    display: block;
    width: 100%;
    margin-bottom: 18px;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    outline: none;
    background: var(--white);
    color: var(--text);
    font-size: 15px;
    transition: border-color .2s ease, box-shadow .2s ease;
}

input:focus,
select:focus,
textarea:focus,
.form-control:focus {
    border-color: var(--secondary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}

textarea {
    min-height: 130px;
    resize: vertical;
}

small {
    display: block;
    margin: -8px 0 18px;
    color: var(--muted);
}

.checkbox-row {
    display: flex;
    align-items: center;
    gap: 10px;
    width: max-content;
    max-width: 100%;
    margin: 14px 0;
    cursor: pointer;
}

.checkbox-row input,
input[type="checkbox"],
input[type="radio"] {
    width: 18px;
    height: 18px;
    margin: 0;
    accent-color: var(--secondary);
}

.tool-code,
.code-editor,
.code-field,
.big-editor {
    min-height: 420px;
    font-family: Consolas, Monaco, monospace;
    line-height: 1.6;
    tab-size: 4;
}

.tool-code,
.code-editor,
.big-editor {
    background: #0F172A;
    color: #E2E8F0;
}

.tox-tinymce {
    margin-bottom: 20px;
    border-color: var(--border) !important;
    border-radius: 8px !important;
}

.faq-item {
    position: relative;
    margin-bottom: 16px;
    padding: 18px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
}

/* ============================== BUTTONS ============================== */

.btn-primary,
.btn-secondary,
.btn-danger,
.btn-view,
.btn-edit,
.btn-delete,
.action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    min-height: 40px;
    padding: 10px 17px;
    border: 1px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 700;
    line-height: 1;
    transition: background-color .2s ease, border-color .2s ease, transform .2s ease;
}

.btn-primary {
    background: var(--secondary);
    color: var(--white);
}

.btn-primary:hover {
    background: var(--accent);
    transform: translateY(-1px);
}

.btn-secondary {
    border-color: var(--border);
    background: var(--surface);
    color: var(--primary);
}

.btn-secondary:hover {
    border-color: #BFDBFE;
    background: #EFF6FF;
}

.btn-danger,
.btn-delete {
    background: #DC2626;
    color: var(--white);
}

.btn-danger:hover,
.btn-delete:hover {
    background: #B91C1C;
}

.btn-view {
    background: #E0F2FE;
    color: #075985;
}

.btn-edit,
.edit,
.edit-btn {
    background: var(--secondary);
    color: var(--white);
}

.btn-delete:disabled,
.btn-danger:disabled {
    cursor: not-allowed;
    background: #CBD5E1;
    color: var(--muted);
}

/* ============================== ALERTS ============================== */

.alert {
    max-width: 1100px;
    margin-bottom: 22px;
    padding: 14px 16px;
    border: 1px solid transparent;
    border-radius: 9px;
}

.alert ul {
    margin: 8px 0 0 20px;
}

.alert-success {
    border-color: #BBF7D0;
    background: #DCFCE7;
    color: #166534;
}

.alert-error {
    border-color: #FECACA;
    background: #FEF2F2;
    color: #991B1B;
}

/* ============================== TABLES ============================== */

.table-wrapper {
    width: 100%;
    margin-bottom: 25px;
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--white);
}

.table-wrapper h2 {
    padding: 20px 20px 0;
    color: var(--primary);
    font-size: 20px;
}

table {
    width: 100%;
    min-width: 720px;
    border-collapse: collapse;
}

th {
    padding: 13px 15px;
    background: var(--primary);
    color: var(--white);
    text-align: left;
    white-space: nowrap;
}

td {
    padding: 13px 15px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

tbody tr:last-child td {
    border-bottom: 0;
}

tbody tr:hover {
    background: #F8FAFC;
}

.table-actions,
.filter-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.delete-form {
    display: inline;
    margin: 0;
}

.status-badge,
.badge,
.featured-badge {
    display: inline-flex;
    align-items: center;
    padding: 5px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 750;
    white-space: nowrap;
}

.status-published,
.published,
.badge-published,
.status-active {
    background: #DCFCE7;
    color: #166534;
}

.status-draft,
.draft,
.badge-draft,
.featured-badge {
    background: #FEF3C7;
    color: #92400E;
}

.status-archived,
.archived,
.badge-archived,
.status-inactive {
    background: #FEE2E2;
    color: #991B1B;
}

.calculator-cell,
.article-cell {
    display: flex;
    align-items: center;
    gap: 12px;
}

.calculator-cell img,
.article-cell img,
.category-thumbnail {
    flex: 0 0 auto;
    border-radius: 8px;
    object-fit: cover;
}

.calculator-cell small,
.article-cell small,
td small {
    display: block;
    margin: 3px 0 0;
    color: var(--muted);
}

.category-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    border-radius: 9px;
    background: #EFF6FF;
    font-size: 26px;
}

.empty-state {
    padding: 42px;
    color: var(--muted);
    text-align: center;
}

/* ============================== FILTERS & PAGINATION ============================== */

.manage-filters {
    display: grid;
    grid-template-columns: minmax(220px, 2fr) minmax(160px, 1fr) minmax(160px, 1fr) auto;
    align-items: end;
    gap: 16px;
    margin: 0 0 24px;
    padding: 20px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--white);
}

.manage-filters input,
.manage-filters select {
    margin-bottom: 0 !important;
}

.admin-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 18px;
    margin-top: 24px;
}

.admin-pagination a {
    color: var(--secondary);
    font-weight: 700;
}

/* ============================== IMAGES ============================== */

.current-image {
    width: max-content;
    max-width: 100%;
    margin: 0 0 20px;
}

.image-preview {
    display: block;
    max-width: min(100%, 260px);
    max-height: 220px;
    border: 1px solid var(--border);
    border-radius: 10px;
    object-fit: cover;
}

.current-image figcaption {
    margin-top: 7px;
    color: var(--muted);
    font-size: 13px;
}

/* ============================== LOGIN ============================== */

.admin-login-page {
    display: grid;
    min-height: 100vh;
    place-items: center;
    padding: 24px;
    background: linear-gradient(135deg, #F8FAFC, #DBEAFE);
}

.login-card {
    width: 100%;
    max-width: 430px;
    padding: 32px;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: var(--white);
    box-shadow: var(--shadow);
}

.login-card h1 {
    color: var(--primary);
    font-size: 28px;
}

.login-card > p {
    margin: 7px 0 25px;
    color: var(--muted);
}

.login-card .btn-primary {
    width: 100%;
    margin-top: 5px;
}

/* ============================== FOOTER ============================== */

.admin-footer {
    margin-left: var(--sidebar-width);
    padding: 18px 25px;
    border-top: 1px solid var(--border);
    background: var(--white);
    color: var(--muted);
    text-align: center;
}

/* ============================== RESPONSIVE ============================== */

@media (max-width: 1100px) {
    .manage-filters {
        grid-template-columns: 1fr 1fr;
    }

    .dashboard-table-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    :root {
        --header-height: 64px;
    }

    .admin-header {
        position: relative;
        height: auto;
        min-height: var(--header-height);
        padding: 12px 16px;
    }

    .admin-brand h2 {
        font-size: 20px;
    }

    .admin-user {
        max-width: 52%;
        padding: 7px 10px;
        overflow: hidden;
        font-size: 12px;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .admin-sidebar {
        position: relative;
        top: auto;
        bottom: auto;
        width: 100%;
        max-height: none;
        padding: 12px;
        border-right: 0;
        border-bottom: 1px solid var(--border);
    }

    .admin-sidebar ul {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 4px;
    }

    .admin-sidebar li,
    .menu-title {
        margin: 0;
    }

    .menu-title {
        grid-column: 1 / -1;
        padding: 12px 10px 4px;
    }

    .admin-content {
        margin-left: 0;
        padding: 22px 16px;
    }

    .admin-footer {
        margin-left: 0;
    }

    .page-heading {
        flex-direction: column;
        align-items: stretch;
    }

    .page-heading > a,
    .page-heading > button {
        width: 100%;
    }

    .form-section,
    .quick-actions,
    .dashboard-card,
    .login-card {
        padding: 20px;
    }

    .tool-code,
    .code-editor,
    .big-editor {
        min-height: 330px;
    }

    .manage-filters {
        grid-template-columns: 1fr;
    }

    .filter-actions > * {
        flex: 1;
    }

    .quick-action-list > * {
        flex: 1 1 calc(50% - 10px);
    }
}

@media (max-width: 480px) {
    .admin-sidebar ul {
        grid-template-columns: 1fr;
    }

    .menu-title {
        grid-column: auto;
    }

    .admin-content {
        padding: 18px 12px;
    }

    .table-actions {
        min-width: 190px;
    }

    .quick-action-list > * {
        flex-basis: 100%;
    }
}