/* ============================================================
   GEON Client Portal — Material Design styling (core CSS, no framework)
   ============================================================ */

:root {
    --md-primary: #1a73e8;
    --md-primary-dark: #1558b0;
    --md-accent: #00897b;
    --md-danger: #d93025;
    --md-bg: #f1f3f4;
    --md-surface: #ffffff;
    --md-text: #202124;
    --md-text-secondary: #5f6368;
    --md-border: #dadce0;
    --shadow-1: 0 1px 2px 0 rgba(60,64,67,.3), 0 1px 3px 1px rgba(60,64,67,.15);
    --shadow-2: 0 1px 3px 0 rgba(60,64,67,.3), 0 4px 8px 3px rgba(60,64,67,.15);
    --radius: 12px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
    background: var(--md-bg);
    color: var(--md-text);
}

/* ---------- Top App Bar ---------- */
.app-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--md-primary);
    color: #fff;
    padding: 0 24px;
    height: 64px;
    box-shadow: var(--shadow-1);
    position: sticky;
    top: 0;
    z-index: 10;
}
.app-bar .brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 20px;
    font-weight: 500;
}
.app-bar .brand .material-icons { font-size: 28px; }
.app-bar .user-info {
    display: flex;
    align-items: center;
    gap: 16px;
    font-size: 14px;
}
.app-bar .user-info .customer-name { font-weight: 500; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border: none;
    border-radius: 6px;
    padding: 10px 24px;
    font-size: 14px;
    font-weight: 500;
    letter-spacing: .25px;
    cursor: pointer;
    text-decoration: none;
    transition: background .2s, box-shadow .2s;
}
.btn .material-icons { font-size: 18px; }
.btn-primary { background: var(--md-primary); color: #fff; }
.btn-primary:hover { background: var(--md-primary-dark); box-shadow: var(--shadow-1); }
.btn-outline {
    background: transparent;
    color: var(--md-primary);
    border: 1px solid var(--md-border);
}
.btn-outline:hover { background: rgba(26,115,232,.06); }
.btn-danger-text { background: transparent; color: var(--md-danger); }
.btn-danger-text:hover { background: rgba(217,48,37,.08); }
.btn-block { width: 100%; }
.btn-icon {
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--md-text-secondary);
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.btn-icon:hover { background: rgba(60,64,67,.08); }

/* ---------- Login page ---------- */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: linear-gradient(135deg, #1a73e8 0%, #6ab0ff 100%);
}
.login-card {
    background: var(--md-surface);
    width: 100%;
    max-width: 400px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-2);
    padding: 40px 36px 32px;
}
.login-card .logo {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    margin-bottom: 24px;
}
.login-card .logo .material-icons {
    font-size: 44px;
    color: var(--md-primary);
    background: rgba(26,115,232,.1);
    padding: 14px;
    border-radius: 50%;
}
.login-card h1 { font-size: 20px; font-weight: 500; margin: 0; }
.login-card p.subtitle { color: var(--md-text-secondary); font-size: 13px; margin: 4px 0 0; }

.field {
    position: relative;
    margin-bottom: 22px;
}
.field .material-icons.field-icon {
    position: absolute;
    left: 12px;
    top: 14px;
    font-size: 20px;
    color: var(--md-text-secondary);
}
.field input {
    width: 100%;
    padding: 14px 14px 14px 42px;
    font-size: 14px;
    border: 1px solid var(--md-border);
    border-radius: 6px;
    outline: none;
    transition: border-color .2s, box-shadow .2s;
    background: #fff;
    color: var(--md-text);
}
.field input:focus {
    border-color: var(--md-primary);
    box-shadow: 0 0 0 1px var(--md-primary);
}
.field label {
    position: absolute;
    left: 42px;
    top: -9px;
    background: #fff;
    padding: 0 4px;
    font-size: 12px;
    color: var(--md-text-secondary);
}
.field .toggle-visibility {
    position: absolute;
    right: 8px;
    top: 8px;
}

.alert {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 14px;
    border-radius: 6px;
    font-size: 13px;
    margin-bottom: 20px;
}
.alert-error { background: #fce8e6; color: #c5221f; }
.alert-success { background: #e6f4ea; color: #137333; }
.alert .material-icons { font-size: 18px; }

.login-footer {
    text-align: center;
    margin-top: 20px;
    font-size: 12px;
    color: var(--md-text-secondary);
}

/* ---------- Dashboard / Application Access ---------- */
.page-wrap {
    max-width: 1200px;
    margin: 0 auto;
    padding: 32px 24px 60px;
}
.page-header { margin-bottom: 24px; }
.page-header h2 { font-size: 22px; font-weight: 500; margin: 0 0 4px; }
.page-header p { color: var(--md-text-secondary); font-size: 14px; margin: 0; }

.app-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

.app-card {
    background: var(--md-surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-1);
    padding: 22px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    transition: box-shadow .2s, transform .2s;
}
.app-card:hover { box-shadow: var(--shadow-2); transform: translateY(-2px); }

.app-card-top { display: flex; align-items: center; gap: 14px; }
.app-icon {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 24px;
    flex-shrink: 0;
}
.app-card-title { flex-grow: 1; }
.app-card-title h3 { margin: 0; font-size: 16px; font-weight: 500; text-transform: capitalize; }
.app-card-title span.host { font-size: 12px; color: var(--md-text-secondary); }

.status-chip {
    font-size: 11px;
    font-weight: 500;
    padding: 3px 10px;
    border-radius: 12px;
    text-transform: uppercase;
    letter-spacing: .4px;
}
.status-active { background: #e6f4ea; color: #137333; }
.status-inactive { background: #fce8e6; color: #c5221f; }

.app-card-body {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 12px 14px;
    font-size: 13px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.app-card-body .row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.app-card-body .row .label { color: var(--md-text-secondary); display: flex; align-items: center; gap: 6px; }
.app-card-body .row .label .material-icons { font-size: 15px; }
.app-card-body .row .value { font-family: 'Roboto Mono', monospace; font-size: 12.5px; word-break: break-all; }

.app-card-actions {
    display: flex;
    gap: 8px;
    margin-top: 4px;
}

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--md-text-secondary);
}
.empty-state .material-icons { font-size: 56px; color: var(--md-border); margin-bottom: 12px; }

/* ---------- Page header row (title + action button) ---------- */
.page-header-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

/* ---------- Search bar ---------- */
.search-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--md-surface);
    border: 1px solid var(--md-border);
    border-radius: 8px;
    padding: 8px 14px;
    margin-bottom: 20px;
    max-width: 560px;
}
.search-bar .material-icons { color: var(--md-text-secondary); font-size: 20px; }
.search-bar input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 14px;
    padding: 6px 0;
    background: transparent;
    color: var(--md-text);
}
.search-bar .btn { padding: 8px 18px; }

/* ---------- Data table ---------- */
.table-card {
    background: var(--md-surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-1);
    overflow: hidden;
}
.table-scroll { overflow-x: auto; }
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}
.data-table thead th {
    text-align: left;
    padding: 14px 16px;
    background: #f8f9fa;
    color: var(--md-text-secondary);
    font-weight: 500;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .4px;
    border-bottom: 1px solid var(--md-border);
    white-space: nowrap;
}
.data-table tbody td {
    padding: 12px 16px;
    border-bottom: 1px solid #f0f1f2;
    vertical-align: middle;
    white-space: nowrap;
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: #f8f9fa; }
.data-table td.col-actions, .data-table th.col-actions { text-align: right; }

.app-cell { display: flex; align-items: center; gap: 10px; }
.app-icon-sm {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    flex-shrink: 0;
}
.app-icon-sm .material-icons { font-size: 16px; }

.action-btns { display: inline-flex; align-items: center; gap: 4px; }
.inline-form { display: inline-flex; margin: 0; }
.btn-icon-danger:hover { background: rgba(217,48,37,.1); color: var(--md-danger); }

/* ---------- Table footer / pagination ---------- */
.table-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    padding: 14px 18px;
    border-top: 1px solid var(--md-border);
}
.results-count { font-size: 12.5px; color: var(--md-text-secondary); }

.pagination { display: flex; align-items: center; gap: 4px; }
.page-btn {
    min-width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    font-size: 13px;
    text-decoration: none;
    color: var(--md-text);
    padding: 0 6px;
}
.page-btn:hover { background: rgba(60,64,67,.08); }
.page-btn.active { background: var(--md-primary); color: #fff; font-weight: 500; }
.page-btn.disabled { color: var(--md-border); pointer-events: none; }
.page-btn .material-icons { font-size: 18px; }

/* ---------- Add / Edit form ---------- */
.page-wrap-narrow { max-width: 760px; }
.back-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--md-primary);
    text-decoration: none;
    font-size: 13.5px;
    margin-bottom: 16px;
}
.back-link .material-icons { font-size: 18px; }
.back-link:hover { text-decoration: underline; }

.form-card {
    background: var(--md-surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-1);
    padding: 28px 32px 32px;
}
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-top: 8px;
}
.field-full { grid-column: 1 / -1; }

.field-plain label {
    display: block;
    font-size: 12.5px;
    font-weight: 500;
    color: var(--md-text-secondary);
    margin-bottom: 6px;
}
.field-plain input,
.field-plain select {
    width: 100%;
    padding: 11px 12px;
    font-size: 14px;
    border: 1px solid var(--md-border);
    border-radius: 6px;
    outline: none;
    background: #fff;
    color: var(--md-text);
    transition: border-color .2s, box-shadow .2s;
    font-family: inherit;
}
.field-plain input:focus,
.field-plain select:focus {
    border-color: var(--md-primary);
    box-shadow: 0 0 0 1px var(--md-primary);
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 28px;
    padding-top: 20px;
    border-top: 1px solid var(--md-border);
}

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

.snackbar {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: #323232;
    color: #fff;
    padding: 12px 20px;
    border-radius: 6px;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: var(--shadow-2);
    opacity: 0;
    pointer-events: none;
    transition: opacity .25s;
    z-index: 999;
}
.snackbar.show { opacity: 1; }
