/*
Theme Name: EMG App Theme
Theme URI: https://emg.essexmeats.co.uk
Author: OpenAI
Version: 0.1.6
Description: Front-end application shell theme for EMG.
Text Domain: emg-app-theme
*/

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
    --emg-admin-bar: 0px;
    --emg-sidebar-width: 280px;
    --emg-gap: 28px;
    --emg-header-height: 74px;

    --emg-bg: #f3f6fb;
    --emg-surface: #ffffff;
    --emg-surface-2: #f8fafc;
    --emg-text: #0f172a;
    --emg-muted: #64748b;
    --emg-border: #dde5f0;
    --emg-primary: #2563eb;
    --emg-primary-hover: #1d4ed8;
    --emg-shadow: 0 10px 30px rgba(15, 23, 42, 0.08);

    --emg-sidebar-bg: linear-gradient(180deg, #08162f 0%, #0f2245 100%);
    --emg-sidebar-text: #e5edf9;
    --emg-sidebar-active: rgba(255,255,255,0.12);
}

body.emg-theme-dark {
    --emg-bg: #0b1220;
    --emg-surface: #111a2b;
    --emg-surface-2: #0f1726;
    --emg-text: #e5edf8;
    --emg-muted: #94a3b8;
    --emg-border: rgba(148, 163, 184, 0.22);
    --emg-primary: #3b82f6;
    --emg-primary-hover: #2563eb;
    --emg-shadow: 0 14px 34px rgba(0, 0, 0, 0.35);

    --emg-sidebar-bg: linear-gradient(180deg, #050b16 0%, #0b1424 100%);
    --emg-sidebar-text: #f8fbff;
    --emg-sidebar-active: rgba(255,255,255,0.10);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    min-height: 100%;
    background: var(--emg-bg);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 15px;
    line-height: 1.55;
    color: var(--emg-text);
    transition: background-color .2s ease, color .2s ease;
}

body.admin-bar { --emg-admin-bar: 32px; }
@media (max-width: 782px) {
    body.admin-bar { --emg-admin-bar: 46px; }
}

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

.entry-title,
.wp-block-post-title,
main > .wp-block-group > h1:first-child,
.emg-main > h1:first-child {
    display: none !important;
}

.emg-site {
    min-height: calc(100vh - var(--emg-admin-bar));
    width: 100%;
}

.emg-header {
    height: var(--emg-header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 0 24px;
    background: color-mix(in srgb, var(--emg-surface) 92%, white 8%);
    border-bottom: 1px solid var(--emg-border);
    position: sticky;
    top: var(--emg-admin-bar);
    z-index: 60;
    backdrop-filter: blur(10px);
}

.emg-header-left,
.emg-header-right {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
}

.emg-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--emg-text);
    min-width: 0;
}

.emg-brand-mark {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: linear-gradient(135deg, #2563eb, #6d4cff);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.04em;
    flex-shrink: 0;
    box-shadow: 0 12px 24px rgba(37, 99, 235, 0.28);
}

.emg-brand-text strong {
    display: block;
    font-size: 16px;
    line-height: 1.1;
    white-space: nowrap;
}

.emg-brand-text span {
    display: block;
    font-size: 12px;
    line-height: 1.2;
    color: var(--emg-muted);
    white-space: nowrap;
}

.emg-header-chip,
.emg-theme-toggle {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    height: 42px;
    padding: 0 14px;
    border: 1px solid var(--emg-border);
    border-radius: 999px;
    background: var(--emg-surface);
    color: var(--emg-text);
    font: inherit;
    font-weight: 600;
}

.emg-status-dot {
    width: 10px;
    height: 10px;
    border-radius: 999px;
    background: #22c55e;
    box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.14);
}

.emg-theme-toggle {
    cursor: pointer;
}

.emg-theme-toggle:hover {
    background: var(--emg-surface-2);
}

.emg-main {
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 24px;
}

.emg-app,
.emg-shell,
.emg-layout,
.emg-app-shell,
.emg-dashboard-shell,
.emg-front-shell,
.emg-system-shell {
    display: flex;
    align-items: flex-start;
    gap: var(--emg-gap);
    width: 100%;
    max-width: none !important;
    min-height: calc(100vh - var(--emg-admin-bar) - var(--emg-header-height) - 48px);
}

.emg-sidebar,
.emg-app-sidebar,
.emg-shell-sidebar,
.emg-dashboard-sidebar {
    width: var(--emg-sidebar-width);
    min-width: var(--emg-sidebar-width);
    max-width: var(--emg-sidebar-width);
    background: var(--emg-sidebar-bg);
    color: var(--emg-sidebar-text);
    border-radius: 24px;
    box-shadow: var(--emg-shadow);
    padding: 22px 18px 18px;
    position: sticky;
    top: calc(var(--emg-admin-bar) + var(--emg-header-height) + 24px);
    max-height: calc(100vh - var(--emg-admin-bar) - var(--emg-header-height) - 48px);
    overflow: auto;
}

.emg-sidebar * ,
.emg-app-sidebar *,
.emg-shell-sidebar *,
.emg-dashboard-sidebar * {
    min-width: 0;
}

.emg-sidebar > :first-child,
.emg-app-sidebar > :first-child,
.emg-shell-sidebar > :first-child,
.emg-dashboard-sidebar > :first-child {
    display: none !important;
}

.emg-sidebar a,
.emg-app-sidebar a,
.emg-shell-sidebar a,
.emg-dashboard-sidebar a {
    color: var(--emg-sidebar-text);
}

.emg-sidebar .active,
.emg-app-sidebar .active,
.emg-shell-sidebar .active,
.emg-dashboard-sidebar .active,
.emg-sidebar [aria-current="page"],
.emg-app-sidebar [aria-current="page"],
.emg-shell-sidebar [aria-current="page"],
.emg-dashboard-sidebar [aria-current="page"] {
    background: var(--emg-sidebar-active);
    border-radius: 14px;
}

.emg-sidebar > :last-child,
.emg-app-sidebar > :last-child,
.emg-shell-sidebar > :last-child,
.emg-dashboard-sidebar > :last-child {
    margin-top: 18px;
    overflow: hidden;
}

.emg-sidebar .emg-user-email,
.emg-app-sidebar .emg-user-email,
.emg-shell-sidebar .emg-user-email,
.emg-dashboard-sidebar .emg-user-email,
.emg-sidebar [class*="email"],
.emg-app-sidebar [class*="email"],
.emg-shell-sidebar [class*="email"],
.emg-dashboard-sidebar [class*="email"] {
    overflow-wrap: anywhere;
    word-break: break-word;
    white-space: normal;
    font-size: 13px;
    line-height: 1.35;
}

.emg-content,
.emg-app-content,
.emg-shell-content,
.emg-dashboard-content,
.emg-page-content,
.emg-workspace {
    flex: 1 1 auto;
    min-width: 0;
    width: auto;
    max-width: none !important;
    padding-left: 0;
}

.emg-content > *,
.emg-app-content > *,
.emg-shell-content > *,
.emg-dashboard-content > *,
.emg-page-content > *,
.emg-workspace > * {
    background: var(--emg-surface);
    border: 1px solid var(--emg-border);
    border-radius: 24px;
    box-shadow: var(--emg-shadow);
    padding: 28px;
    margin: 0 0 24px 0;
    width: 100%;
    max-width: none !important;
    overflow: hidden;
}

.emg-content .emg-card,
.emg-app-content .emg-card,
.emg-shell-content .emg-card,
.emg-dashboard-content .emg-card,
.emg-page-content .emg-card,
.emg-workspace .emg-card,
.emg-content .emg-panel,
.emg-app-content .emg-panel,
.emg-shell-content .emg-panel,
.emg-dashboard-content .emg-panel,
.emg-page-content .emg-panel,
.emg-workspace .emg-panel {
    background: transparent;
    border: 0;
    box-shadow: none;
    border-radius: 0;
    padding: 0;
    margin-bottom: 24px;
}

.emg-page-title {
    font-size: 38px;
    font-weight: 700;
    letter-spacing: -0.03em;
    line-height: 1.05;
    margin: 0 0 10px;
}

.emg-page-subtitle,
.emg-muted {
    color: var(--emg-muted);
}

.emg-btn,
button,
input[type="submit"],
.wp-block-button__link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: var(--emg-primary);
    color: #fff;
    border: 0;
    border-radius: 12px;
    padding: 11px 18px;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}

.emg-btn:hover,
button:hover,
input[type="submit"]:hover,
.wp-block-button__link:hover {
    background: var(--emg-primary-hover);
    color: #fff;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
select,
textarea {
    width: 100%;
    min-width: 0;
    border: 1px solid #ccd6e5;
    border-radius: 14px;
    padding: 12px 14px;
    font: inherit;
    color: var(--emg-text);
    background: color-mix(in srgb, var(--emg-surface) 94%, white 6%);
}

body.emg-theme-dark input[type="text"],
body.emg-theme-dark input[type="email"],
body.emg-theme-dark input[type="password"],
body.emg-theme-dark input[type="number"],
body.emg-theme-dark input[type="date"],
body.emg-theme-dark select,
body.emg-theme-dark textarea {
    border-color: rgba(148, 163, 184, 0.22);
    background: #0f1726;
}

table,
.emg-table {
    width: 100%;
    border-collapse: collapse;
    background: transparent;
}

th, td {
    padding: 13px 14px;
    border-bottom: 1px solid color-mix(in srgb, var(--emg-border) 85%, transparent 15%);
    text-align: left;
    vertical-align: top;
}

th {
    color: var(--emg-muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 700;
}

.emg-grid,
.emg-stats-grid,
.emg-cards-grid,
.emg-dashboard-grid {
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    gap: 24px;
    width: 100%;
    max-width: none !important;
}

.emg-grid > *,
.emg-stats-grid > *,
.emg-cards-grid > *,
.emg-dashboard-grid > * {
    grid-column: span 3;
    min-width: 0;
}

.emg-auto-grid {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(320px, 1fr);
    gap: 24px;
    margin-bottom: 24px;
    align-items: start;
}

.emg-auto-card {
    background: var(--emg-surface);
    border: 1px solid var(--emg-border);
    border-radius: 24px;
    box-shadow: var(--emg-shadow);
    padding: 28px;
    overflow: hidden;
    min-width: 0;
}

.emg-auto-card h2,
.emg-auto-card h3 {
    margin-top: 0;
}

.emg-auto-card .emg-grid,
.emg-auto-card .emg-stats-grid,
.emg-auto-card .emg-cards-grid,
.emg-auto-card .emg-dashboard-grid {
    margin-top: 0;
}

.emg-customer-directory-card table,
.emg-customer-directory-card .emg-table {
    margin-top: 10px;
}

.emg-footer {
    padding: 18px 24px 24px;
    color: var(--emg-muted);
    font-size: 12px;
    text-align: center;
}

@media (max-width: 1180px) {
    .emg-main { padding: 18px; }

    .emg-app,
    .emg-shell,
    .emg-layout,
    .emg-app-shell,
    .emg-dashboard-shell,
    .emg-front-shell,
    .emg-system-shell {
        flex-direction: column;
    }

    .emg-sidebar,
    .emg-app-sidebar,
    .emg-shell-sidebar,
    .emg-dashboard-sidebar {
        width: 100%;
        min-width: 0;
        max-width: none;
        position: relative;
        top: auto;
        max-height: none;
        border-radius: 20px;
    }

    .emg-grid > *,
    .emg-stats-grid > *,
    .emg-cards-grid > *,
    .emg-dashboard-grid > * {
        grid-column: span 6;
    }

    .emg-auto-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    .emg-header {
        height: auto;
        padding: 14px 16px;
    }

    .emg-brand-text span,
    .emg-header-chip span {
        display: none;
    }

    .emg-main { padding: 14px; }
    .emg-page-title { font-size: 30px; }

    .emg-content > *,
    .emg-app-content > *,
    .emg-shell-content > *,
    .emg-dashboard-content > *,
    .emg-page-content > *,
    .emg-workspace > * {
        padding: 20px;
        border-radius: 18px;
    }

    .emg-auto-card {
        padding: 20px;
        border-radius: 18px;
    }

    .emg-grid > *,
    .emg-stats-grid > *,
    .emg-cards-grid > *,
    .emg-dashboard-grid > * {
        grid-column: span 12;
    }
}
