/* GENERAL */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --background: #0b0f14;
    --surface: #141a22;
    --surface-hover: #1b2430;
    --border: #252f3b;
    --text: #f1f5f9;
    --muted: #8995a5;
    --accent: #65d6a1;
    --blue: #65b8ed;
}

body {
    background: var(--background);
    color: var(--text);
    font-family: Arial, Helvetica, sans-serif;
    min-height: 100vh;
}

/* HEADER */
.topbar {
    height: 70px;
    padding: 0 6%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #10161e;
    border-bottom: 1px solid var(--border);
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 20px;
    font-weight: 700;
}

.brand-icon {
    color: var(--accent);
    font-size: 26px;
}

.header-status {
    color: var(--muted);
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 9px;
}

.status-dot {
    width: 8px;
    height: 8px;
    background: var(--accent);
    border-radius: 50%;
}

/* MAIN CONTENT */
.container {
    max-width: 1250px;
    margin: 0 auto;
    padding: 55px 30px;
}

.page-heading {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 35px;
}

.eyebrow {
    color: var(--accent);
    font-size: 11px;
    letter-spacing: 2px;
    font-weight: bold;
    margin-bottom: 12px;
}

h1 {
    font-size: 34px;
    margin-bottom: 10px;
}

.subtitle {
    color: var(--muted);
    font-size: 14px;
}

.pet-count {
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 10px 16px;
    border-radius: 10px;
    color: var(--muted);
    font-size: 13px;
}

/* PET GRID */
.pet-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 22px;
}

.pet-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 15px;
    overflow: hidden;
    cursor: pointer;
    transition: 0.2s ease;
}

.pet-card:hover {
    transform: translateY(-4px);
    background: var(--surface-hover);
    border-color: #526477;
}

.pet-image {
    width: 100%;
    height: 180px;
    object-fit: cover;
    display: block;
    background: #202b37;
}

.pet-card-content {
    padding: 20px;
}

.pet-card-heading {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.pet-card-heading h2 {
    font-size: 19px;
}

.species {
    color: var(--muted);
    font-size: 12px;
    margin-top: 5px;
}

.metrics {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.metric {
    background: #10161e;
    border-radius: 10px;
    padding: 13px;
}

.metric-label {
    color: var(--muted);
    font-size: 11px;
    margin-bottom: 8px;
}

.metric-value {
    font-size: 23px;
    font-weight: 700;
}

.temperature {
    color: var(--accent);
}

.humidity {
    color: var(--blue);
}

/* INDIVIDUAL PET VIEW */
.hidden {
    display: none !important;
}

.back-button {
    border: none;
    background: none;
    color: var(--muted);
    cursor: pointer;
    font-size: 14px;
    margin-bottom: 30px;
}

.back-button:hover {
    color: var(--accent);
}

.pet-detail-header {
    margin-bottom: 25px;
}

.pet-detail-header h1 {
    margin-bottom: 8px;
}

.detail-image {
    width: 100%;
    height: 350px;
    object-fit: cover;
    border-radius: 16px;
    border: 1px solid var(--border);
    margin-bottom: 25px;
}

.detail-metrics {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
}

.detail-metrics .metric {
    padding: 25px;
}

.detail-metrics .metric-value {
    font-size: 36px;
}

.sensor-info {
    color: var(--muted);
    font-size: 13px;
    margin-top: 25px;
}

/* FOOTER */
footer {
    text-align: center;
    color: var(--muted);
    font-size: 12px;
    padding: 30px;
    border-top: 1px solid var(--border);
}

footer span {
    color: var(--accent);
    margin: 0 5px;
}



/* ===================================
   DASHBOARD ACTIONS
=================================== */

.dashboard-actions {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
}

#add-pet-button {
    background: #263c34;
    color: var(--accent);
    border: 1px solid #3d6858;
    border-radius: 10px;
    padding: 11px 18px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.2s ease;
}

#add-pet-button:hover {
    background: #345748;
}

/* ===================================
   ADD PET MODAL
=================================== */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 1000;
}

.modal-overlay.hidden {
    display: none;
}

.modal {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 28px;
    width: 100%;
    max-width: 440px;
    max-height: 90vh;
    overflow-y: auto;
    color: var(--text);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.modal-header h2 {
    font-size: 22px;
}

#close-modal {
    background: none;
    border: none;
    color: var(--muted);
    font-size: 28px;
    cursor: pointer;
}

#close-modal:hover {
    color: var(--text);
}

#add-pet-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

#add-pet-form label {
    color: var(--muted);
    font-size: 13px;
}

#add-pet-form input {
    width: 100%;
    background: #202b37;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px;
    color: var(--text);
    font: inherit;
}

#add-pet-form input:focus {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}

.save-pet-button {
    background: #263c34;
    color: var(--accent);
    border: 1px solid #3d6858;
    padding: 13px;
    border-radius: 9px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 12px;
}

.save-pet-button:hover {
    background: #345748;
}

.save-pet-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.form-error {
    color: #ff8b8b;
    font-size: 13px;
}

.form-error:empty {
    display: none;
}



/* ===================================
   PET MANAGEMENT ACTIONS
=================================== */

.pet-view-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-bottom: 30px;
}

.pet-view-actions .back-button {
    margin-bottom: 0;
}

.pet-management-actions {
    display: flex;
    gap: 10px;
}

#edit-pet-button,
#delete-pet-button {
    padding: 10px 16px;
    border-radius: 9px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease;
}

#edit-pet-button {
    background: #263c34;
    color: #65d6a1;
    border: 1px solid #3d6858;
}

#edit-pet-button:hover {
    background: #345748;
}

#delete-pet-button {
    background: #3a2025;
    color: #ff9292;
    border: 1px solid #704047;
}

#delete-pet-button:hover {
    background: #542b32;
}

/* PET PHOTO UPLOAD */

#pet-photo {
    cursor: pointer;
}

#pet-photo::file-selector-button {
    background: #263c34;
    color: #65d6a1;
    border: 1px solid #3d6858;
    border-radius: 7px;
    padding: 9px 12px;
    margin-right: 12px;
    cursor: pointer;
}

#pet-photo::file-selector-button:hover {
    background: #345748;
}

.upload-hint {
    color: var(--muted);
    font-size: 12px;
    line-height: 1.5;
}




/* ===================================
   MOBILE
=================================== */

@media (max-width: 600px) {

    .container {
        padding: 35px 18px;
    }

    .page-heading {
        flex-direction: column;
        align-items: flex-start;
        gap: 18px;
    }

    .dashboard-actions {
        flex-wrap: wrap;
        justify-content: flex-start;
    }

    h1 {
        font-size: 27px;
    }

    .pet-grid {
        grid-template-columns: 1fr;
    }

    .detail-image {
        height: 230px;
    }

    .detail-metrics {
        grid-template-columns: 1fr;
    }

    .pet-view-actions {
        flex-direction: column;
        align-items: flex-start;
    }

    .pet-management-actions {
        width: 100%;
    }
}
/* THERMOPRO SENSOR PICKER */
.sensor-picker { display: flex; gap: 8px; flex-wrap: wrap; }
#pet-sensor { flex: 1 1 190px; min-width: 0; background: #202b37; border: 1px solid var(--border); border-radius: 8px; padding: 12px; color: var(--text); font: inherit; }
#refresh-sensors { background: #263c34; color: var(--accent); border: 1px solid #3d6858; border-radius: 8px; padding: 10px; cursor: pointer; }
#refresh-sensors:disabled { opacity: .5; cursor: wait; }

/* LAST FED TRACKER */
.feeding-metric { grid-column: 1 / -1; }
.feeding-value { font-size: 15px; color: var(--text); line-height: 1.4; }
.detail-metrics .feeding-value { font-size: 19px; }
.feed-pet-button {
    width: 100%; margin-top: 14px; padding: 12px 16px;
    background: #263c34; color: var(--accent);
    border: 1px solid #3d6858; border-radius: 9px;
    font-size: 14px; font-weight: 600; cursor: pointer;
}
.feed-pet-button:hover { background: #345748; }
.feed-pet-button:disabled { opacity: .5; cursor: wait; }
.detail-feed-button { max-width: 260px; }

/* FEEDING TIME MANAGEMENT */
.feeding-secondary-actions { display: flex; gap: 8px; margin-top: 8px; }
.feeding-secondary-actions button {
    flex: 1; padding: 9px 12px; border-radius: 8px; cursor: pointer;
    background: #202b37; color: var(--text); border: 1px solid var(--border);
    font: inherit; font-size: 13px;
}
.feeding-secondary-actions button:hover:not(:disabled) { background: #30404e; }
.feeding-secondary-actions button:disabled { opacity: .4; cursor: not-allowed; }
.detail-feeding-actions { max-width: 350px; }
.detail-feeding-actions .detail-feed-button { max-width: none; }
.feeding-edit-dialog {
    position: fixed;
    inset: 0;
    margin: auto;
    width: min(92vw, 420px);
    max-height: 90vh;
    overflow-y: auto;
    border: 1px solid var(--border); border-radius: 14px;
    padding: 24px; background: #17212c; color: var(--text);
    box-shadow: 0 20px 70px #0009;
}
.feeding-edit-dialog::backdrop { background: #000a; }
.feeding-edit-form { display: grid; gap: 12px; }
.feeding-edit-form h2 { margin: 0; }
.feeding-edit-form p { margin: 0; }
.feeding-edit-form label { font-size: 13px; }
.feeding-edit-form input {
    width: 100%; box-sizing: border-box; padding: 12px; border-radius: 8px;
    border: 1px solid var(--border); background: #202b37; color: var(--text);
    color-scheme: dark; font: inherit;
}
.feeding-edit-error { color: #ff9999; font-size: 13px; }
.feeding-edit-actions { display: flex; gap: 8px; justify-content: flex-end; }
.feeding-edit-actions button {
    padding: 10px 14px; border-radius: 8px; cursor: pointer;
    border: 1px solid var(--border); background: #263c34; color: var(--text);
}
.feeding-edit-actions button:disabled { opacity: .5; }

/* SHARED ADMIN LOGIN */
.auth-screen { position:fixed; inset:0; z-index:5000; display:grid; place-items:center; padding:20px; background:#0b0f14; }
.auth-panel { width:min(100%,420px); display:flex; flex-direction:column; gap:13px; padding:30px; border:1px solid var(--border); border-radius:16px; background:var(--surface); }
.auth-panel h1 { text-align:center; color:var(--accent); }
.auth-panel p { color:var(--muted); font-size:14px; line-height:1.5; }
.auth-panel label { color:var(--muted); font-size:13px; }
.auth-panel input { background:#202b37; color:var(--text); border:1px solid var(--border); border-radius:8px; padding:12px; font:inherit; }
.auth-panel input[readonly] { opacity:.7; }
.auth-panel button { padding:13px; border-radius:9px; border:1px solid #3d6858; background:#263c34; color:var(--accent); font-weight:700; cursor:pointer; }
.auth-panel button:disabled { opacity:.5; }
.auth-panel #auth-error { color:#ff9292; }
.auth-panel .auth-hint { text-align:center; font-size:12px; }
#logout-button { border:1px solid var(--border); border-radius:8px; background:#202b37; color:var(--text); padding:8px 12px; cursor:pointer; }
