/* Simple CRM — Stylesheet
   © 2026 Paul C. Kruger. GPL
   -------------------------------------------------- */

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

:root {
    --primary:      #1a3a5c;
    --primary-dark: #122844;
    --accent:       #2980b9;
    --accent-hover: #2471a3;
    --danger:       #c0392b;
    --danger-hover: #a93226;
    --success:      #27ae60;
    --warn:         #e67e22;
    --bg:           #eef2f7;
    --card-bg:      #ffffff;
    --border:       #d0d9e4;
    --text:         #2c3e50;
    --text-muted:   #6b7f96;
    --label-color:  #4a5f75;
    --radius:       8px;
    --shadow:       0 2px 8px rgba(0,0,0,.10), 0 1px 2px rgba(0,0,0,.06);
    --shadow-hover: 0 6px 18px rgba(0,0,0,.13), 0 2px 4px rgba(0,0,0,.07);
    --font: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

html { font-size: 16px; }

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Buttons ── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    padding: .48rem 1rem;
    border-radius: var(--radius);
    font-size: .875rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    white-space: nowrap;
    transition: background .15s, box-shadow .15s, opacity .15s;
    text-decoration: none;
}
.btn:hover { text-decoration: none; opacity: .92; }

.btn-primary   { background: var(--accent);  color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }

.btn-secondary { background: #fff; color: var(--primary); border: 1.5px solid var(--border); }
.btn-secondary:hover { background: var(--bg); }

.btn-ghost     { background: transparent; color: var(--text-muted); border: 1.5px solid var(--border); }
.btn-ghost:hover { background: #fff; }

.btn-search    { background: var(--primary); color: #fff; }
.btn-search:hover { background: var(--primary-dark); }

.btn-full      { width: 100%; justify-content: center; padding: .65rem 1rem; font-size: 1rem; }

.btn-sm { padding: .3rem .7rem; font-size: .8rem; }
.btn-edit   { background: var(--accent); color: #fff; }
.btn-edit:hover { background: var(--accent-hover); }
.btn-delete { background: var(--danger); color: #fff; }
.btn-delete:hover { background: var(--danger-hover); }

/* ── App Header ── */
.app-header {
    background: var(--primary);
    color: #fff;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 6px rgba(0,0,0,.25);
}
.header-inner {
    max-width: 1400px;
    margin: 0 auto;
    padding: .75rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.app-title {
    font-size: 1.3rem;
    font-weight: 700;
    color: #fff;
    letter-spacing: .04em;
    text-decoration: none;
    flex-shrink: 0;
}

/* ── Search Form ── */
.search-form {
    display: flex;
    align-items: center;
    gap: .5rem;
    flex: 1;
    min-width: 220px;
}
.search-form input[type="search"] {
    flex: 1;
    padding: .45rem .75rem;
    border-radius: var(--radius);
    border: none;
    font-size: .9rem;
    outline: none;
    background: rgba(255,255,255,.15);
    color: #fff;
    min-width: 0;
}
.search-form input[type="search"]::placeholder { color: rgba(255,255,255,.65); }
.search-form input[type="search"]:focus { background: rgba(255,255,255,.25); }
.search-form input[type="search"]::-webkit-search-cancel-button { display: none; }

.header-nav {
    display: flex;
    align-items: center;
    gap: .5rem;
    flex-shrink: 0;
}

/* ── Main Content ── */
.main-content {
    flex: 1;
    max-width: 1400px;
    width: 100%;
    margin: 0 auto;
    padding: 1.5rem;
}

.result-count {
    font-size: .875rem;
    color: var(--text-muted);
    margin-bottom: 1.1rem;
}

.empty-state {
    text-align: center;
    color: var(--text-muted);
    margin-top: 4rem;
    font-size: 1.05rem;
}

/* ── Card Grid ── */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.25rem;
}

/* ── Customer Card ── */
.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    transition: box-shadow .2s;
    overflow: hidden;
}
.card:hover { box-shadow: var(--shadow-hover); }

.card-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: .75rem;
    padding: 1rem 1rem .75rem;
    border-bottom: 1px solid var(--border);
}
.card-name-wrap { display: flex; flex-direction: column; gap: .35rem; min-width: 0; }
.card-name {
    font-size: 1rem;
    font-weight: 700;
    color: var(--primary);
    line-height: 1.3;
    word-break: break-word;
}
.card-actions {
    display: flex;
    gap: .4rem;
    flex-shrink: 0;
    align-items: center;
}
.card-actions form { margin: 0; }

.card-body {
    padding: .85rem 1rem 1rem;
    display: flex;
    flex-direction: column;
    gap: .6rem;
    flex: 1;
}

/* ── Address / Map Link ── */
.card-address {
    font-size: .875rem;
    color: var(--text-muted);
    line-height: 1.5;
}
.map-link {
    color: var(--text-muted);
    text-decoration: none;
    border-bottom: 1px dashed var(--border);
    transition: color .15s, border-color .15s;
    display: inline-block;
}
.map-link:hover {
    color: var(--accent);
    border-bottom-color: var(--accent);
    text-decoration: none;
}

/* ── Contact List ── */
.contact-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: .35rem;
}
.contact-list li {
    display: flex;
    align-items: baseline;
    gap: .5rem;
    font-size: .875rem;
}
.contact-label {
    font-size: .75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--text-muted);
    min-width: 40px;
    flex-shrink: 0;
}
.contact-list a {
    color: var(--accent);
    word-break: break-all;
}
.contact-list a:hover { text-decoration: underline; }

/* ── Type Badges ── */
.badge {
    display: inline-block;
    padding: .2rem .55rem;
    border-radius: 20px;
    font-size: .7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    width: fit-content;
}
.badge-personal     { background: #e8f5e9; color: #2e7d32; }
.badge-professional { background: #e3f2fd; color: #1565c0; }
.badge-business     { background: #f3e5f5; color: #6a1b9a; }
.badge-other        { background: #f0f0f0; color: #555; }

/* ── Auth Pages (Login / Setup) ── */
.auth-page {
    justify-content: center;
    align-items: center;
    background: var(--primary);
}
.auth-box {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: 0 8px 32px rgba(0,0,0,.25);
    padding: 2.5rem 2rem;
    width: 100%;
    max-width: 360px;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}
.auth-box h1 {
    text-align: center;
    color: var(--primary);
    font-size: 1.75rem;
    letter-spacing: .05em;
}

/* ── Form Elements (shared) ── */
label {
    display: flex;
    flex-direction: column;
    gap: .35rem;
    font-size: .875rem;
    font-weight: 600;
    color: var(--label-color);
}
input[type="text"],
input[type="email"],
input[type="tel"],
input[type="password"],
input[type="search"],
select {
    padding: .5rem .75rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    font-size: .95rem;
    font-family: var(--font);
    color: var(--text);
    background: #fff;
    transition: border-color .15s, box-shadow .15s;
    width: 100%;
}
input:focus, select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(41,128,185,.15);
}

/* ── Notices ── */
.notice {
    padding: .65rem .9rem;
    border-radius: var(--radius);
    font-size: .875rem;
    font-weight: 500;
}
.notice.error { background: #fdecea; color: #b71c1c; }
.notice.ok    { background: #e8f5e9; color: #1b5e20; }
.notice.warn  { background: #fff3e0; color: #e65100; }

.req { color: var(--danger); }

.setup-notice {
    background: #fff3e0;
    color: #e65100;
    padding: .5rem .75rem;
    border-radius: var(--radius);
    font-size: .82rem;
    text-align: center;
}

/* ── Form Page Layout ── */
.form-page {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding-top: 2rem;
}
.form-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 2rem;
    width: 100%;
    max-width: 640px;
    display: flex;
    flex-direction: column;
    gap: 1.1rem;
}
.form-card h2 {
    color: var(--primary);
    font-size: 1.25rem;
    margin-bottom: .25rem;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}
.form-row-csz {
    grid-template-columns: 1fr auto auto;
    align-items: end;
}
.w-state { width: 90px; }
.w-zip   { width: 110px; }
.flex-grow { flex: 1; }

.error-list {
    background: #fdecea;
    color: #b71c1c;
    border-radius: var(--radius);
    padding: .75rem 1rem .75rem 1.5rem;
    font-size: .875rem;
    display: flex;
    flex-direction: column;
    gap: .3rem;
}

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

/* ── Footer ── */
.site-footer {
    text-align: center;
    padding: 1rem;
    font-size: .78rem;
    color: var(--text-muted);
    border-top: 1px solid var(--border);
    margin-top: auto;
}
.auth-page .site-footer {
    color: rgba(255,255,255,.45);
    border-top-color: rgba(255,255,255,.1);
}

/* ── Responsive ── */
@media (max-width: 700px) {
    .header-inner  { gap: .6rem; }
    .search-form   { order: 3; width: 100%; }
    .form-row      { grid-template-columns: 1fr; }
    .form-row-csz  { grid-template-columns: 1fr 1fr; }
    .w-state, .w-zip { width: auto; }
    .card-grid     { grid-template-columns: 1fr; }
    .form-card     { padding: 1.25rem; }
    .auth-box      { margin: 1rem; }
}
