/* =========================================================
   APP.CSS – CORE UI STYLESHEET
   ---------------------------------------------------------
   Structured in ZONES.
   Each zone has a clear responsibility.
========================================================= */


/* =========================================================
   ZONE 0 – GLOBAL RESET & DEFAULTS
========================================================= */

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--text-color, #333);
    background: #fff;
}


/* =========================================================
   ZONE 1 – GLOBAL PAGE SHELL
========================================================= */

.page {
    max-width: 1200px;
    margin: 0 auto;
    padding: 12px;
}

.page-content {
    max-width: 900px;
    margin: 0 auto;
    padding: 16px 0 32px;
}

.page-content h2 {
    text-align: center;
    margin-bottom: 6px;
    color: var(--primary-color);
}

.page-description {
    text-align: center;
    color: #555;
    margin-bottom: 28px;
}

.auth-wrapper {
    max-width: 420px;
    margin: 40px auto;
    padding: 24px;
}

/* LOGIN LOGO SYSTEM (WIDTH CONTROLLED) */

.auth-logo {
    width: 100%;
    display: flex;
    justify-content: center;
}

.auth-logo img.logo {
    width: min(90%, var(--login-logo-max-width));
    height: auto;
    display: block;
}

@media (max-width: 600px) {
    .auth-logo img.logo {
        width: min(90%, var(--login-logo-max-width-mobile));
    }
}
 


.auth-container {
    max-width: 420px;
    margin: 0 auto;
}

@media (min-width: 1024px) {
    .auth-container {
        max-width: 480px;
    }
}


/* =========================================================
   VISIBILITY HELPERS
========================================================= */

.mobile-only { display: none; }
.desktop-only { display: inline; }

@media (max-width: 600px) {
    .mobile-only { display: inline; }
    .desktop-only { display: none; }
}


/* =========================================================
   ZONE 1A – HEADER & TOP ACTIONS
========================================================= */

.header {
    text-align: center;
    margin-bottom: 28px;
}

.header h1 {
    margin: 0 0 10px 0;
    color: var(--primary-color);
}

/* TOP ACTIONS */
.top-actions {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin: 0 auto;
}

/* HEADER BUTTON – FIXED CENTERING */
.action-btn {
    display: flex;
    align-items: center;
    justify-content: center;

    height: 48px;
    padding: 0 24px;

    line-height: 1;
    font-weight: 600;     /* cleaner */
    font-size: 14px;      /* enforce equal size */

    background: var(--button-color);
    color: var(--button-text-color);
    border-radius: 10px;
    text-decoration: none;
    border: none;
    cursor: pointer;
    min-width: 240px;
    text-align: center;
}

.action-btn:hover {
    background: var(--button-hover-color);
}


/* =========================================================
   USER MENU (DROPDOWN)
========================================================= */

.user-menu {
    position: relative;
}

.user-btn {
    min-width: 140px;
}

.user-dropdown {
    display: none;
    position: absolute;
    top: 110%;
    right: 0;
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 6px 18px rgba(0,0,0,0.15);
    overflow: hidden;
    min-width: 160px;
    z-index: 100;
}

.user-dropdown a {
    display: block;
    padding: 12px 14px;
    text-decoration: none;
    color: #333;
    font-weight: 600;
}

.user-dropdown a:hover {
    background: #f2f2f2;
}


/* Desktop hover */
@media (min-width: 601px) {
    .user-menu:hover .user-dropdown {
        display: block;
    }
}


/* =========================================================
   MOBILE HEADER – 2 BUTTONS ACROSS
========================================================= */

@media (max-width: 600px) {
    .top-actions {
        display: grid;
        grid-template-columns: repeat(2, 1fr); /* 🔹 changed to 2 */
        gap: 8px;
        align-items: stretch;
    }


    .action-btn {
        width: 100%;
        min-height: 40px;
        min-width: 180px;
        padding: 14px 6px;
        font-size: 13px;
    }

    .user-dropdown {
        position: absolute;
        right: 0;
        box-shadow: 0 6px 18px rgba(0,0,0,0.15);
        border: none;
        margin-top: 6px;
        min-width: 100%;       /* 🔹 dropdown matches button width */
    }
}



/* =========================================================
   FLASH / NOTICE MESSAGES
========================================================= */

.notice-success.inline {
    color: var(--button-color);
    font-weight: 700;
    letter-spacing: 0.4px;
    text-align: center;
    margin: 18px 0 14px;
}

.notice-success,
.notice-error {
    max-width: 760px;
    margin: 16px auto;
    padding: 12px 16px;
    border-radius: 10px;
    font-weight: bold;
    text-align: center;
}



.notice-error {
    background: rgba(239,68,68,0.15);
    color: #7f1d1d;
}


.notice-error {
    background: rgba(239,68,68,0.15);
    color: #7f1d1d;
}


/* =========================================================
   ZONE 2 – DASHBOARD & MENUS
========================================================= */

.menu {
    display: grid;
    gap: 10px;
    width: 100%;
    max-width: 1000px;
    margin: 0 auto;
}

.menu-item {
    text-align: center;
}

.menu-item a {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 56px;
    padding: 14px 18px;
    background: var(--button-color);
    color: var(--button-text-color);
    font-weight: bold;
    text-decoration: none;
    border-radius: 14px;
}

.menu-item a:hover {
    background: var(--button-hover-color);
}

@media (max-width: 600px) {
    .menu {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 601px) {
    .menu {
        grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    }
}

.menu-item.disabled a {
    opacity: 0.5;
    pointer-events: none;
    cursor: default;
}


/* =========================================================
   ZONE 3 – FORMS
========================================================= */

.page-content form {
    max-width: 760px;
    margin: 0 auto;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-weight: bold;
    margin-bottom: 6px;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 10px 12px;
    font-size: 14px;
    border-radius: 8px;
    border: 1px solid #ccc;
}

.form-group textarea {
    min-height: 80px;
    resize: vertical;
}


/* =========================================================
   ZONE 3A – FORM GRIDS
========================================================= */

.customer-grid,
.form-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 24px;
}

@media (max-width: 600px) {
    .customer-grid,
    .form-row {
        grid-template-columns: 1fr;
        gap: 14px;
    }
}


/* =========================================================
   ZONE 3B – FORM ACTIONS
========================================================= */

.form-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-top: 24px;
}

@media (max-width: 600px) {
    .form-actions {
        grid-template-columns: 1fr;
    }
}

.btn-primary,
.btn-secondary {
    display: block;
    width: 100%;
    padding: 12px;
    border-radius: 10px;
    font-weight: bold;
    text-align: center;
    cursor: pointer;
}

.btn-primary {
    background: var(--button-color);
    color: var(--button-text-color);
}

.btn-primary:hover {
    background: var(--button-hover-color);
}

.btn-secondary {
    background: #e0e0e0;
    color: #000;
}

/* =========================================================
   MODAL BASICS
========================================================= */

.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 16px; /* 🔑 THIS LINE */
}

.modal.hidden {
    display: none;
}

.modal-card {
    background: #fff;
    width: 90%;
    max-width: 320px;
    max-height: 90vh;
    padding: 12px;
    border-radius: 12px;
    overflow-y: auto;
}

@media (max-width: 480px) {
    .modal-card {
        padding: 14px;
        border-radius: 10px;
    }
}


/* =========================================================
   AUTH – LOGIN ONLY (SAFE SCOPED)
========================================================= */

.auth-box {
    max-width: 520px;
    margin: 0 auto;
}

.auth-box .form-actions.single {
    grid-template-columns: 1fr;
}

@media (min-width: 768px) {
    .auth-box {
        max-width: 600px;
    }
}

/* =========================================
   Search dropdowns (Customers / Contacts)
========================================= */

.search-results {
    margin-top: 8px;
    background: #ffffff;
    border: 1px solid #ddd;
    border-radius: 6px;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.08);
    max-height: 220px;
    overflow-y: auto;
    z-index: 1000;
}

.search-results div {
    padding: 10px 12px;
    cursor: pointer;
    font-size: 14px;
    border-bottom: 1px solid #f0f0f0;
color: #222;
 background-color: #ffe0b2;
}

.search-results div:last-child {
    border-bottom: none;
}

.search-results div:hover {
    background-color: #fff3e0; /* soft orange, matches theme */
}

/* =========================================
   Disabled inline link (Create contact)
========================================= */

.inline-link.is-disabled {
    pointer-events: none;
    opacity: 0.5;
    cursor: not-allowed;
}

/* ======================================
   HEADER SIZE TWEAK (SAFE OVERRIDE)
====================================== */


@media (max-width: 600px) {
    .header .action-btn {
        height: 34px;    /* 🔧 Mobile height control */
    }
}

