/* ---------- ORIGINAL STYLES (unchanged) ---------- */
/* Reset */
body {
    margin: 0;
    min-height: 100vh;
    /* ensures full height */
    display: flex;
    flex-direction: column;
    /* for sticky footer */
    font-family: Arial, sans-serif;
    background: #f4f6f9;
    color: #333;
}

/* Header */
header {
    background: #1e88e5;
    color: white;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

header h1 {
    margin: 0;
}

nav a {
    color: white;
    margin-left: 15px;
    text-decoration: none;
    font-weight: bold;
}

nav a:hover {
    text-decoration: underline;
}

/* Main content */
main {
    flex: 1;
    /* pushes footer down */
    padding: 30px;
    max-width: 1000px;
    /* limit width for readability */
    margin: 0 auto;
    width: 100%;
}

/* Reminder Section */
.reminders {
    background: white;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Reminder Form */
.reminder-form {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 20px;
}

.reminder-form input,
.reminder-form select,
.reminder-form button {
    padding: 8px;
    border: 1px solid #ccc;
    border-radius: 6px;
}

.reminder-form button {
    background: #1e88e5;
    color: white;
    border: none;
    cursor: pointer;
}

.reminder-form button:hover {
    background: #1565c0;
}

/* Recurrence Box ✅ */
.recurrence-box {
    display: flex;
    gap: 10px;
    align-items: center;
}

.recurrence-box label {
    font-weight: bold;
}

.recurrence-box select,
.recurrence-box input {
    padding: 6px;
    border-radius: 6px;
    border: 1px solid #ccc;
    font-size: 14px;
}

/* Table (desktop) */
.reminder-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
    /* keep table within viewport */
    background: white;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.reminder-table th,
.reminder-table td {
    border: 1px solid #ddd;
    padding: 8px;
    text-align: center;
    font-size: 13px;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.reminder-table th {
    background: #f1f1f1;
}

.reminder-table tr:hover {
    background: #f9f9f9;
}

/* Highlight tasks assigned by someone else (created_by != assigned_to) */
.reminder-table tr.assigned-other {
    background: #d4edda;
}

.reminder-table tr.assigned-other:hover {
    background: #c3e6cb;
}

/* ✅ Description Column Styling (desktop) */
.reminder-table td:nth-child(3) {
    max-width: 180px;
    white-space: normal;
    word-wrap: break-word;
    text-align: left;
    font-size: 14px;
    color: #444;
}

/* Status row colors */
.pending {
    background: #fffde7;
}

.completed {
    background: #e8f5e9;
}

.approved {
    background: #e3f2fd;
}

.rejected {
    background: #ffebee;
}

/* Buttons */
.btn {
    padding: 6px 12px;
    border-radius: 5px;
    border: none;
    cursor: pointer;
}

.btn.complete {
    background: #4caf50;
    color: white;
}

.btn.approve {
    background: #2196f3;
    color: white;
}

.btn.reject {
    background: #f44336;
    color: white;
}

.btn:hover {
    opacity: 0.9;
}

/* Footer */
footer {
    background: #1e88e5;
    color: white;
    text-align: center;
    padding: 10px;
    margin-top: auto;
    /* keeps footer at bottom */
}

/* ======================= */
/* Login Page Styles       */
/* ======================= */
.login-box {
    max-width: 400px;
    margin: 50px auto;
    background: white;
    padding: 25px;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    text-align: center;
}

.login-box h2 {
    margin-top: 0;
    margin-bottom: 20px;
    color: #1e88e5;
}

.login-box input {
    width: 100%;
    margin-bottom: 12px;
    padding: 10px;
    border-radius: 6px;
    border: 1px solid #ccc;
    font-size: 14px;
}

.login-box button {
    width: 100%;
    padding: 10px;
    background: #1e88e5;
    border: none;
    border-radius: 6px;
    color: white;
    font-size: 15px;
    cursor: pointer;
}

.login-box button:hover {
    background: #1565c0;
}

.error {
    color: red;
    margin-bottom: 15px;
    font-size: 14px;
}

/* ======================= */
/* Mobile/Responsive Tweaks*/
/* ======================= */

/* Improve touch feedback & tap size */
* {
    -webkit-tap-highlight-color: transparent;
}

button,
.btn,
nav a {
    min-height: 44px;
    line-height: 1.2;
}

/* Header + nav wrap nicely on small screens */
header {
    flex-wrap: wrap;
    gap: 10px;
}

header h1 {
    font-size: 1.1rem;
}

nav {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

/* Optional wrapper for horizontal scroll if you keep tables on tablets */
.table-responsive {
    width: 100%;
    overflow-x: auto;
}

.table-responsive::-webkit-scrollbar {
    height: 8px;
}

.table-responsive::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 4px;
}

/* ================================ */
/* 📱 Turn tables into cards (<=640px) */
/* ================================ */
@media (max-width: 640px) {

    /* Hide table header, turn rows into cards */
    .reminder-table,
    .reminder-table thead,
    .reminder-table tbody,
    .reminder-table th,
    .reminder-table tr {
        display: block;
        width: 100%;
    }

    .reminder-table thead {
        /* Off-screen header */
        position: absolute;
        left: -9999px;
        top: -9999px;
    }

    .reminder-table tr {
        background: #fff;
        margin-bottom: 12px;
        border: 1px solid #e5e7eb;
        border-radius: 10px;
        box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
        overflow: hidden;
    }

    .reminder-table td {
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        border: none;
        border-bottom: 1px solid #f0f0f0;
        padding: 10px 12px;
        text-align: left;
        /* better for labels + values */
        gap: 12px;
    }

    .reminder-table td:last-child {
        border-bottom: none;
    }

    /* Labels on the left: use the cell's data-label (works for all tables) */
    .reminder-table td::before {
        content: attr(data-label);
        /* label column */
        flex: 0 0 40%;
        color: #555;
        font-weight: 600;
    }

    .reminder-table td>* {
        /* value column */
        flex: 1 1 auto;
    }

    /* Make description breathe on mobile */
    .reminder-table td:nth-child(3) {
        white-space: normal;
        word-wrap: break-word;
        font-size: 14px;
    }

    /* Stack action buttons nicely */
    .reminder-table td:last-child form {
        display: inline-block;
        margin-right: 8px;
        margin-bottom: 6px;
    }

    .btn,
    .reminder-form button,
    .login-box button {
        width: 100%;
    }

    main {
        padding: 16px;
    }

    .reminders {
        padding: 16px;
    }

    nav a {
        padding: 6px 8px;
    }
}

/* Slight font-size adjustment on small tablets */
@media (max-width: 768px) {

    .reminder-table th,
    .reminder-table td {
        padding: 10px;
        font-size: 14px;
    }
}

/* Optional: make the create/edit forms grid on tablets */
@media (min-width: 768px) {
    .reminder-form {
        display: grid;
        grid-template-columns: repeat(6, 1fr);
    }

    .reminder-form .form-group {
        grid-column: span 3;
    }

    .reminder-form button {
        grid-column: span 6;
    }
}

/* ---------- NEW: SQLite / DB UI Styles ---------- */

/* Panel that shows DB info, file name, record count and quick actions */
.db-panel {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    background: linear-gradient(180deg, #ffffff, #fbfdff);
    border: 1px solid #e6eef9;
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 16px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.03);
}

.db-info {
    display: flex;
    gap: 12px;
    align-items: center;
    font-size: 14px;
    color: #2f4f7b;
}

.db-info .label {
    font-weight: 600;
    color: #1e88e5;
    margin-right: 6px;
}

.db-info .value {
    color: #444;
}

/* File list for .sqlite files / DB backups */
.db-file-list {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.sqlite-file {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: #fff;
    border: 1px solid #e9eef6;
    padding: 6px 10px;
    border-radius: 6px;
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.03);
    font-size: 13px;
}

.sqlite-file .name {
    max-width: 180px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

/* DB action buttons (export, import, vacuum, seed, migrate) */
.db-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.export-btn,
.import-btn,
.vacuum-btn,
.seed-btn,
.migrate-btn {
    background: #1976d2;
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
}

.import-btn {
    background: #2e7d32;
}

/* green for import */
.vacuum-btn {
    background: #ff9800;
}

/* orange for maintenance */
.seed-btn {
    background: #6a1b9a;
}

/* purple for seed */
.migrate-btn {
    background: #00838f;
}

/* teal for migrate */
.export-btn:disabled,
.import-btn:disabled,
.vacuum-btn:disabled,
.seed-btn:disabled,
.migrate-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Inline DB status badges */
.db-badge {
    display: inline-block;
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    color: white;
}

.db-badge.ok {
    background: #4caf50;
}

.db-badge.warn {
    background: #ffb300;
}

.db-badge.offline {
    background: #f44336;
}

/* Simple embedded SQL query box */
.query-box {
    margin-top: 12px;
    display: flex;
    gap: 8px;
    align-items: flex-start;
    flex-wrap: wrap;
}

.query-box textarea {
    width: 100%;
    min-height: 120px;
    padding: 12px;
    border-radius: 8px;
    border: 1px solid #d6dce9;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, "Roboto Mono", monospace;
    font-size: 13px;
    resize: vertical;
}

.query-box .run-query {
    background: #1e88e5;
    color: white;
    border: none;
    padding: 10px 14px;
    border-radius: 8px;
    cursor: pointer;
}

.query-box .run-query:hover {
    background: #166ac4;
}

/* Result list for record-level display */
.record-list {
    margin-top: 12px;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #e7eef9;
}

.record-row {
    display: flex;
    gap: 12px;
    padding: 10px;
    align-items: center;
    border-bottom: 1px solid #f2f6fb;
    background: #fff;
    font-size: 14px;
}

.record-row:last-child {
    border-bottom: none;
}

.record-row .col {
    flex: 1 1 auto;
    color: #333;
}

.record-row .actions {
    flex: 0 0 auto;
    display: flex;
    gap: 6px;
}

/* Empty-state & errors for DB results */
.db-empty {
    padding: 16px;
    text-align: center;
    color: #667788;
}

.db-error {
    padding: 12px;
    background: #ffebee;
    color: #b00020;
    border-radius: 6px;
    border: 1px solid #ffd6d6;
}

/* Offline indicator (useful if DB is not accessible) */
.offline {
    display: inline-flex;
    gap: 8px;
    align-items: center;
    color: #c62828;
    font-weight: 700;
}

/* Tiny loading spinner for async DB actions */
.spinner {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 2px solid rgba(0, 0, 0, 0.12);
    border-top-color: rgba(0, 0, 0, 0.35);
    animation: spin 0.9s linear infinite;
    display: inline-block;
    vertical-align: middle;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Accessibility / reduced motion */
@media (prefers-reduced-motion: reduce) {
    .spinner {
        animation: none;
    }

    * {
        transition: none !important;
    }
}

/* Small responsive tweaks for DB panel */
@media (max-width: 720px) {
    .db-info {
        font-size: 13px;
    }

    .sqlite-file .name {
        max-width: 120px;
    }

    .query-box textarea {
        min-height: 96px;
    }

    .record-row {
        padding: 8px;
        font-size: 13px;
    }
}