/* Meowderall - Touch-friendly CSS for iPad */

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

:root {
    --primary: #4a90a4;
    --primary-dark: #357a8a;
    --bg: #f5f5f5;
    --card-bg: #ffffff;
    --text: #333333;
    --text-light: #666666;
    --border: #dddddd;
    --success: #4caf50;
    --warning: #ff9800;
    --min-tap: 44px;
}

html, body {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 18px;
    line-height: 1.5;
    background: var(--bg);
    color: var(--text);
    -webkit-text-size-adjust: 100%;
}

/* Prevent zoom on input focus (iOS) */
input, select, textarea {
    font-size: 16px;
}

.app {
    max-width: 1024px;
    margin: 0 auto;
    padding: 1rem;
}

h1 {
    font-size: 2rem;
    margin: 0 0 0.5rem 0;
    color: var(--primary-dark);
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.tagline {
    font-size: 1.1rem;
    color: var(--text-light);
    margin: 0 0 0.5rem 0;
}

.admin-badge {
    display: inline-block;
    background: var(--success);
    color: #fff;
    padding: 0.25rem 0.75rem;
    border-radius: 4px;
    font-size: 0.85rem;
    font-weight: 600;
    margin: 0;
}

.btn-small {
    min-height: 36px;
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
}

.btn-logout {
    background: var(--text-light);
}

.btn-admin-toggle {
    font-size: 0.85rem;
}

.header-buttons {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.header-actions {
    display: flex;
    gap: 0.5rem;
}

.pin-warning {
    display: inline-block;
    background: var(--warning);
    color: #fff;
    padding: 0.25rem 0.75rem;
    border-radius: 4px;
    font-size: 0.85rem;
    font-weight: 600;
    margin: 0;
}

.pin-input-group {
    margin-bottom: 1rem;
}

.pin-input-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--text-light);
}

.pin-text-input {
    width: 100%;
    padding: 0.75rem;
    font-size: 1.5rem;
    text-align: center;
    letter-spacing: 0.5rem;
    border: 2px solid var(--border);
    border-radius: 8px;
}

.pin-text-input:focus {
    outline: none;
    border-color: var(--primary);
}

.change-pin-modal {
    max-width: 320px;
}

/* Date inputs */
.date-inputs {
    grid-column: span 2;
}

.date-input-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}

.date-input {
    flex: 1;
    min-width: 140px;
}

/* Export section */
.export-section {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.btn-export {
    flex: 1;
    min-width: 140px;
    background: var(--primary-dark);
}

.github-link {
    width: 100%;
    text-align: center;
    margin-top: 0.5rem;
    font-size: 0.9rem;
}

.github-link a {
    color: var(--text-light);
    text-decoration: none;
}

.github-link a:hover {
    text-decoration: underline;
}

/* Empty state message */
.empty-message {
    text-align: center;
    color: var(--text-light);
    padding: 2rem;
    font-style: italic;
}

/* Tab bar */
.tab-bar {
    margin-bottom: 1rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.tabs {
    display: flex;
    gap: 0.25rem;
    min-width: max-content;
}

.tab {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--border);
    border-radius: 8px 8px 0 0;
    cursor: pointer;
    font-size: 0.9rem;
    white-space: nowrap;
    border: none;
    color: var(--text);
    min-height: var(--min-tap);
}

.tab.active {
    background: var(--card-bg);
    font-weight: 600;
    color: var(--primary-dark);
}

.tab-name {
    flex: 1;
}

.tab-add {
    background: var(--primary);
    color: #fff;
    font-size: 1.25rem;
    font-weight: 600;
    padding: 0.5rem 1rem;
}

.tab-add:active {
    background: var(--primary-dark);
}

.tab-close {
    background: transparent;
    border: none;
    color: #d32f2f;
    font-size: 1.25rem;
    padding: 0;
    min-width: 24px;
    min-height: 24px;
    line-height: 1;
    cursor: pointer;
}

.tab-close:active {
    color: #b71c1c;
}

/* Day controls */
.day-controls {
    display: flex;
    gap: 0.5rem;
    margin: 0.5rem 0;
    flex-wrap: wrap;
}

.btn-day {
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-day:active {
    background: var(--border);
}

.btn-day.btn-danger {
    background: #ffebee;
    color: #d32f2f;
    border-color: #ffcdd2;
}

.btn-day.btn-danger:active {
    background: #ffcdd2;
}

/* Delete confirmation modal */
.delete-modal {
    text-align: center;
}

.delete-message {
    font-size: 1.1rem;
    margin: 0 0 0.5rem 0;
}

.delete-warning {
    color: var(--text-light);
    font-size: 0.9rem;
    margin: 0 0 1.5rem 0;
}

.btn-delete {
    background: #d32f2f;
    color: #fff;
}

.btn-delete:active {
    background: #b71c1c;
}

.notice {
    background: var(--warning);
    color: #fff;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
}

/* Touch-friendly buttons */
button, .btn {
    min-height: var(--min-tap);
    min-width: var(--min-tap);
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    border: none;
    border-radius: 8px;
    background: var(--primary);
    color: #fff;
    cursor: pointer;
    touch-action: manipulation;
}

button:active, .btn:active {
    background: var(--primary-dark);
}

/* Touch-friendly inputs */
input[type="text"],
input[type="number"],
input[type="date"],
textarea {
    min-height: var(--min-tap);
    padding: 0.75rem 1rem;
    border: 2px solid var(--border);
    border-radius: 8px;
    background: var(--card-bg);
    width: 100%;
    touch-action: manipulation;
}

input:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary);
}

/* Card container */
.card {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 1.25rem;
    margin-bottom: 1rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* Form fields */
.field {
    margin-bottom: 1rem;
}

.field label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-light);
}

/* Form grid layout */
.form-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.5rem;
}

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

/* Date range display */
.date-range .date-display {
    min-height: var(--min-tap);
    padding: 0.75rem 1rem;
    background: var(--bg);
    border-radius: 8px;
    font-weight: 600;
}

.date-separator {
    color: var(--text-light);
}

/* Section headers */
.schedule-section h2 {
    margin: 0 0 1rem 0;
    font-size: 1.25rem;
    color: var(--primary-dark);
}

/* Table wrapper for horizontal scroll on small screens */
.table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Date cell in table */
.date-cell {
    font-weight: 600;
    white-space: nowrap;
    background: var(--bg) !important;
}

/* Medication schedule table */
.schedule-table {
    width: 100%;
    border-collapse: collapse;
}

.schedule-table th,
.schedule-table td {
    min-height: var(--min-tap);
    padding: 0.75rem;
    text-align: center;
    border: 1px solid var(--border);
}

.schedule-table th {
    background: var(--primary);
    color: #fff;
    font-weight: 600;
}

.schedule-table td {
    background: var(--card-bg);
}

/* Tappable table cells */
.schedule-table td.tappable {
    cursor: pointer;
    user-select: none;
}

.schedule-table td.tappable:active {
    background: var(--bg);
}

.schedule-table td.filled {
    background: #e8f5e9;
    font-weight: 600;
}

.schedule-table td.locked {
    position: relative;
}

.lock-icon {
    position: absolute;
    top: 2px;
    right: 4px;
    font-size: 0.7rem;
    opacity: 0.5;
}

.protected-header {
    position: relative;
}

/* PIN pad */
.pin-pad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
    max-width: 280px;
    margin: 1rem auto;
}

.pin-pad button {
    height: 64px;
    font-size: 1.5rem;
    font-weight: 600;
}

.pin-btn {
    background: var(--bg);
    color: var(--text);
}

.pin-btn:active {
    background: var(--border);
}

.pin-clear, .pin-back {
    background: var(--border);
    color: var(--text-light);
}

.pin-modal {
    max-width: 320px;
}

.pin-subtitle {
    text-align: center;
    color: var(--text-light);
    margin: 0 0 1rem 0;
    font-size: 0.9rem;
}

.pin-display {
    text-align: center;
    margin-bottom: 1rem;
}

.pin-dots {
    display: inline-flex;
    gap: 1rem;
}

.pin-dot {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--border);
    transition: background 0.15s;
}

.pin-dot.filled {
    background: var(--primary);
}

.pin-error {
    text-align: center;
    color: #d32f2f;
    font-size: 0.9rem;
    margin: 0 0 0.5rem 0;
}

/* Modal overlay */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 1.5rem;
    max-width: 400px;
    width: 100%;
}

.modal h2 {
    margin: 0 0 0.5rem 0;
    text-align: center;
}

.modal-date {
    text-align: center;
    color: var(--text-light);
    margin: 0 0 1rem 0;
}

.modal-input {
    margin-bottom: 1rem;
}

.modal-buttons {
    display: flex;
    gap: 0.75rem;
}

.modal-buttons button {
    flex: 1;
}

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

.btn-primary:active {
    background: var(--primary-dark);
}

.btn-secondary {
    background: var(--bg);
    color: var(--text);
}

.btn-secondary:active {
    background: var(--border);
}

/* Responsive adjustments */
@media (max-width: 600px) {
    html {
        font-size: 16px;
    }

    .app {
        padding: 0.75rem;
    }
}

@media (min-width: 768px) {
    .app {
        padding: 2rem;
    }
}

/* Navbar */
.navbar {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    background: var(--card-bg);
    padding: 0.5rem;
    border-radius: 12px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.nav-item {
    flex: 1;
    min-width: max-content;
    padding: 0.75rem 1rem;
    background: var(--bg);
    color: var(--text);
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.nav-item:hover {
    background: var(--border);
}

.nav-item.active {
    background: var(--primary);
    color: #fff;
}

.nav-item.active:hover {
    background: var(--primary-dark);
}

/* Room dropdown */
select {
    min-height: var(--min-tap);
    padding: 0.75rem 1rem;
    border: 2px solid var(--border);
    border-radius: 8px;
    background: var(--card-bg);
    width: 100%;
    font-size: 16px;
    touch-action: manipulation;
    cursor: pointer;
}

select:focus {
    outline: none;
    border-color: var(--primary);
}

/* Medical Board Page */
.medical-board h2 {
    margin: 0 0 0.5rem 0;
    color: var(--primary-dark);
}

.board-subtitle {
    color: var(--text-light);
    font-size: 0.9rem;
    margin: 0 0 1rem 0;
}

.medical-board-table {
    width: 100%;
    border-collapse: collapse;
}

.medical-board-table th,
.medical-board-table td {
    padding: 0.75rem 0.5rem;
    text-align: left;
    border: 1px solid var(--border);
}

.medical-board-table th {
    background: var(--primary);
    color: #fff;
    font-weight: 600;
    font-size: 0.85rem;
}

.medical-board-table td {
    background: var(--card-bg);
    font-size: 0.9rem;
}

.medical-board-table td.filled {
    background: #e8f5e9;
    font-weight: 600;
}

.clickable-row {
    cursor: pointer;
}

.clickable-row:hover td {
    background: var(--bg);
}

.clickable-row:hover td.filled {
    background: #c8e6c9;
}

/* Room Breakdown Page */
.room-breakdown {
    padding: 0.5rem;
}

.room-breakdown h2 {
    margin: 0 0 1rem 0;
    color: var(--primary-dark);
}

.room-section {
    margin-bottom: 1rem;
}

.room-header {
    margin: 0 0 0.75rem 0;
    color: var(--primary-dark);
    font-size: 1.1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--primary);
}

.cat-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.cat-list-item {
    display: flex;
    flex-direction: column;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border);
}

.cat-list-item:last-child {
    border-bottom: none;
}

.cat-name {
    font-weight: 600;
    color: var(--text);
}

.cat-notes {
    font-size: 0.85rem;
    color: var(--text-light);
    margin-top: 0.25rem;
}

/* Constants/Settings Page */
.constants-page h2 {
    margin: 0 0 1rem 0;
    color: var(--primary-dark);
}

.constants-page h3 {
    margin: 1rem 0 0.5rem 0;
    color: var(--text);
    font-size: 1rem;
}

.settings-info {
    color: var(--text-light);
    font-size: 0.9rem;
    margin: 0 0 1rem 0;
    padding: 0.75rem;
    background: var(--bg);
    border-radius: 8px;
}

.constants-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.constants-item {
    padding: 0.5rem 0.75rem;
    background: var(--bg);
    border-radius: 4px;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

.admin-required {
    text-align: center;
    padding: 2rem;
}

.admin-required p {
    color: var(--text-light);
    margin: 0 0 1rem 0;
}

/* Editable room list */
.constants-item.editable {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
}

.room-name {
    flex: 1;
}

.remove-room-btn {
    padding: 0.25rem 0.75rem;
    min-height: 32px;
    min-width: auto;
    font-size: 0.8rem;
    background: #ffebee;
    color: #d32f2f;
    border: 1px solid #ffcdd2;
}

.remove-room-btn:hover {
    background: #ffcdd2;
}

.add-room-form {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
    margin-bottom: 1rem;
}

.add-room-form input {
    flex: 1;
}

.add-room-form button {
    white-space: nowrap;
}

.reset-section {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}
