/* 
 * Care-Tracker - Styles
 * Clean, modern UI for household pet care tracking
 */

/* ============== Reset & Base ============== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Colors */
    --primary: #4a90d9;
    --primary-dark: #357abd;
    --success: #28a745;
    --success-light: #d4edda;
    --warning: #ffc107;
    --danger: #dc3545;
    --gray-100: #f8f9fa;
    --gray-200: #e9ecef;
    --gray-300: #dee2e6;
    --gray-500: #6c757d;
    --gray-700: #495057;
    --gray-900: #212529;
    
    /* Category colors */
    --cat-medication: #e74c3c;
    --cat-supplement: #9b59b6;
    --cat-food: #27ae60;
    --cat-other: #7f8c8d;
    
    /* Spacing */
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;
    
    /* Border radius */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--gray-100);
    color: var(--gray-900);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ============== Header & Navigation ============== */
header {
    background: white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    position: sticky;
    top: 0;
    z-index: 100;
}

nav {
    max-width: 1200px;
    margin: 0 auto;
    padding: var(--space-md) var(--space-lg);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--primary);
}

.nav-links {
    list-style: none;
    display: flex;
    gap: var(--space-lg);
}

.nav-links a {
    text-decoration: none;
    color: var(--gray-700);
    font-weight: 500;
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-sm);
    transition: all 0.2s;
}

.nav-links a:hover,
.nav-links a.active {
    color: var(--primary);
    background: var(--gray-100);
}

/* ============== Main Content ============== */
main {
    flex: 1;
    max-width: 1200px;
    margin: 0 auto;
    padding: var(--space-xl) var(--space-lg);
    width: 100%;
}

h1 {
    font-size: 2rem;
    margin-bottom: var(--space-sm);
    color: var(--gray-900);
}

.subtitle {
    color: var(--gray-500);
    margin-bottom: var(--space-xl);
}

/* ============== Pet Section ============== */
.pet-section {
    background: white;
    border-radius: var(--radius-lg);
    padding: var(--space-xl);
    margin-bottom: var(--space-xl);
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.pet-section h2 {
    font-size: 1.5rem;
    margin-bottom: 0;
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.pet-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-md);
    margin-bottom: var(--space-lg);
    width: 100%;
}

.pet-header h2 {
    margin: 0;
}

@media (max-width: 768px) {
    .pet-header {
        flex-direction: column;
        align-items: flex-start;
    }
}

.pet-species {
    font-size: 1rem;
    font-weight: normal;
    color: var(--gray-500);
}

.pet-notes {
    color: var(--gray-500);
    font-style: italic;
    margin-bottom: var(--space-lg);
}

/* ============== Task Grid ============== */
.task-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: var(--space-lg);
}

.task-card {
    background: var(--gray-100);
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-md);
    padding: var(--space-lg);
    transition: all 0.3s;
}

.task-card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.task-card.completed {
    background: var(--success-light);
    border-color: var(--success);
}

.task-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-sm);
}

.task-category {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    padding: var(--space-xs) var(--space-sm);
    border-radius: var(--radius-sm);
    color: white;
}

.task-category.medication { background: var(--cat-medication); }
.task-category.supplement { background: var(--cat-supplement); }
.task-category.food { background: var(--cat-food); }
.task-category.other { background: var(--cat-other); }

.task-status {
    font-size: 0.875rem;
    font-weight: 500;
}

.task-card.completed .task-status {
    color: var(--success);
}

.task-name {
    font-size: 1.25rem;
    margin-bottom: var(--space-sm);
}

.task-description {
    color: var(--gray-700);
    font-size: 0.9rem;
    margin-bottom: var(--space-sm);
}

.task-notes {
    background: rgba(255, 193, 7, 0.15);
    border-left: 3px solid var(--warning);
    padding: var(--space-sm);
    font-size: 0.85rem;
    color: var(--gray-700);
    margin-bottom: var(--space-md);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.completion-info {
    font-size: 0.85rem;
    color: var(--gray-500);
    margin-bottom: var(--space-md);
}

/* ============== Buttons ============== */
.btn {
    display: inline-block;
    padding: var(--space-sm) var(--space-lg);
    font-size: 1rem;
    font-weight: 500;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s;
    width: 100%;
}

.btn-complete {
    background: var(--primary);
    color: white;
}

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

.btn-undo {
    background: var(--gray-500);
    color: white;
}

.btn-undo:hover {
    background: var(--gray-700);
}

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

.btn-secondary {
    background: var(--gray-300);
    color: var(--gray-700);
}

/* ============== Modal ============== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background: white;
    padding: var(--space-xl);
    border-radius: var(--radius-lg);
    max-width: 400px;
    width: 90%;
    text-align: center;
}

.modal-content h3 {
    margin-bottom: var(--space-md);
}

.modal-content p {
    margin-bottom: var(--space-lg);
    color: var(--gray-700);
}

.modal-buttons {
    display: flex;
    gap: var(--space-md);
}

.modal-buttons .btn {
    flex: 1;
}

/* ============== History Table ============== */
.history-page {
    background: white;
    border-radius: var(--radius-lg);
    padding: var(--space-xl);
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.history-table-container {
    overflow-x: auto;
}

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

.history-table th,
.history-table td {
    padding: var(--space-md);
    text-align: left;
    border-bottom: 1px solid var(--gray-200);
}

.history-table th {
    background: var(--gray-100);
    font-weight: 600;
    color: var(--gray-700);
}

.history-table tr:hover {
    background: var(--gray-100);
}

.action-badge {
    display: inline-block;
    padding: var(--space-xs) var(--space-sm);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 500;
}

.action-badge.completed {
    background: var(--success-light);
    color: var(--success);
}

.action-badge.undone {
    background: #fce4e4;
    color: var(--danger);
}

/* ============== Empty State ============== */
.empty-state {
    text-align: center;
    padding: var(--space-xl);
    color: var(--gray-500);
}

/* ============== Tabs ============== */
.tabs-container {
    display: flex;
    gap: var(--space-md);
    margin-bottom: var(--space-lg);
    border-bottom: 2px solid var(--gray-200);
}

.tab-link {
    padding: var(--space-sm) var(--space-lg);
    text-decoration: none;
    color: var(--gray-700);
    font-weight: 500;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all 0.2s;
}

.tab-link:hover {
    color: var(--primary);
}

.tab-link.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

/* ============== Grid History ============== */
.grid-table-container {
    overflow-x: auto;
    margin-bottom: var(--space-lg);
    background: white;
    border-radius: var(--radius-md);
}

.grid-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

.grid-table th, 
.grid-table td {
    padding: var(--space-sm);
    text-align: center;
    border-right: 1px solid var(--gray-200);
    border-bottom: 1px solid var(--gray-200);
    min-width: 80px;
}

.grid-table th {
    background: var(--gray-100);
    font-size: 0.75rem;
    font-weight: 600;
    vertical-align: middle;
}

.grid-table th .pet-name {
    display: block;
    color: var(--gray-500);
    text-transform: uppercase;
    font-size: 0.65rem;
    margin-bottom: 2px;
}

.grid-table .date-col {
    text-align: left;
    min-width: 120px;
    background: var(--gray-100);
    position: sticky;
    left: 0;
    z-index: 10;
    font-weight: 500;
    border-left: 1px solid var(--gray-200);
}

.grid-status {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    font-size: 0.7rem;
    font-weight: bold;
}

.grid-status.given {
    background: var(--success);
    color: white;
}

.grid-status.missed {
    background: var(--danger);
    color: white;
}

.grid-status.na {
    background: var(--gray-200);
    color: var(--gray-500);
}

/* ============== Pagination ============== */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: var(--space-md);
    margin-top: var(--space-xl);
}

.btn-pagination {
    padding: var(--space-sm) var(--space-lg);
    text-decoration: none;
    background: white;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-sm);
    color: var(--gray-700);
    font-size: 0.9rem;
    transition: all 0.2s;
}

.btn-pagination:hover {
    background: var(--gray-100);
    border-color: var(--primary);
    color: var(--primary);
}

.btn-pagination.disabled {
    opacity: 0.5;
    pointer-events: none;
    background: var(--gray-100);
}

.page-info {
    color: var(--gray-500);
    font-size: 0.9rem;
}

.today-badge {
    display: inline-block;
    background: var(--primary);
    color: white;
    font-size: 0.65rem;
    padding: 1px 4px;
    border-radius: 4px;
    margin-left: 4px;
    vertical-align: middle;
}

.pill-pocket-badge {
    display: inline-block;
    background: #ff7675; /* A soft red/pink color */
    color: white;
    font-size: 0.65rem;
    padding: 1px 6px;
    border-radius: 10px;
    margin-left: 4px;
    vertical-align: middle;
    font-weight: 600;
    text-transform: uppercase;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

/* ============== Timer ============== */
.pet-timer {
    background: linear-gradient(135deg, #e1f5fe 0%, #b3e5fc 100%);
    border: 1px solid #03a9f4;
    border-radius: 20px;
    padding: 6px 12px;
    box-shadow: 0 2px 4px rgba(3, 169, 244, 0.15);
    animation: pulse-timer 3s ease-in-out infinite;
    display: inline-flex;
    align-items: center;
}

.pet-timer.timer-ready {
    background: linear-gradient(135deg, #c8e6c9 0%, #a5d6a7 100%);
    border-color: var(--success);
    animation: pulse-ready 2s ease-in-out infinite;
}

@keyframes pulse-timer {
    0%, 100% { 
        box-shadow: 0 2px 4px rgba(3, 169, 244, 0.15);
        transform: translateY(0);
    }
    50% { 
        box-shadow: 0 3px 8px rgba(3, 169, 244, 0.25);
        transform: translateY(-1px);
    }
}

@keyframes pulse-ready {
    0%, 100% { 
        box-shadow: 0 2px 4px rgba(76, 175, 80, 0.2);
    }
    50% { 
        box-shadow: 0 4px 12px rgba(76, 175, 80, 0.35);
    }
}

.timer-content {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 600;
    color: #01579b;
    font-size: 0.8rem;
    line-height: 1.2;
}

.timer-icon {
    font-size: 0.95rem;
    flex-shrink: 0;
}

.timer-label {
    white-space: nowrap;
    font-size: 0.75rem;
    font-weight: 500;
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.timer-countdown {
    font-family: 'SF Mono', 'Monaco', 'Cascadia Code', 'Roboto Mono', monospace;
    font-size: 0.95rem;
    font-weight: 700;
    letter-spacing: 0.3px;
    white-space: nowrap;
    flex-shrink: 0;
    color: #0277bd;
}

.btn-clear-timer {
    background: rgba(255, 255, 255, 0.7);
    border: none;
    border-radius: 50%;
    color: #0277bd;
    cursor: pointer;
    font-size: 0.75rem;
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    margin-left: 4px;
    opacity: 0.7;
    transition: all 0.2s;
    line-height: 1;
    flex-shrink: 0;
}

.btn-clear-timer:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.95);
    transform: scale(1.1);
}

/* ============== Footer ============== */
footer {
    background: white;
    border-top: 1px solid var(--gray-200);
    padding: var(--space-md) var(--space-lg);
    text-align: center;
    color: var(--gray-500);
    font-size: 0.9rem;
}

/* ============== User Identity (Header) ============== */
.nav-user {
    display: flex;
    align-items: center;
    border-left: 1px solid var(--gray-200);
    padding-left: var(--space-md);
    margin-left: var(--space-xs);
}

.nav-user-btn {
    background: var(--gray-100);
    border: 1px solid var(--gray-200);
    border-radius: 20px;
    padding: var(--space-xs) var(--space-md);
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    color: var(--gray-700);
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    max-width: 180px;
}

.nav-user-btn:hover {
    background: white;
    border-color: var(--primary);
    color: var(--primary);
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.nav-user-btn #current-user-name {
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-icon {
    font-size: 0.9rem;
}

/* Modal styles preserved */
.search-container {
    position: relative;
    width: 100%;
    margin-bottom: var(--space-lg);
}

#user-search-input {
    width: 100%;
    padding: var(--space-md);
    border: 2px solid var(--gray-300);
    border-radius: var(--radius-md);
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s;
}

#user-search-input:focus {
    border-color: var(--primary);
}

.search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid var(--gray-300);
    border-top: none;
    border-radius: 0 0 var(--radius-md) var(--radius-md);
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    z-index: 1001;
    max-height: 200px;
    overflow-y: auto;
}

.search-item {
    padding: var(--space-md);
    cursor: pointer;
    text-align: left;
    transition: background 0.2s;
}

.search-item:hover {
    background: var(--gray-100);
    color: var(--primary);
}

/* ============== Visibility & Empty States ============== */
.private-indicator {
    font-size: 0.75rem;
    vertical-align: middle;
    margin-left: 4px;
}

.empty-entity-hint {
    text-align: center;
    padding: var(--space-lg);
    color: var(--gray-500);
    font-size: 0.9rem;
}

.empty-entity-hint a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
}

.empty-entity-hint a:hover {
    text-decoration: underline;
}

.empty-state a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
}

.empty-state a:hover {
    text-decoration: underline;
}

/* ============== Responsive ============== */
@media (max-width: 768px) {
    nav {
        flex-direction: column;
        gap: var(--space-md);
    }

    .nav-user {
        border-left: none;
        padding-left: 0;
        margin-left: 0;
        width: 100%;
        justify-content: center;
    }

    .nav-user-btn {
        max-width: 100%;
        width: 100%;
        justify-content: center;
    }
    
    .task-grid {
        grid-template-columns: 1fr;
    }
    
    .history-table {
        font-size: 0.85rem;
    }
    
    .history-table th,
    .history-table td {
        padding: var(--space-sm);
    }
    
    /* Timer responsive adjustments */
    .pet-timer {
        width: 100%;
        max-width: 100%;
        padding: 8px 10px;
        border-radius: 16px;
    }
    
    .timer-content {
        font-size: 0.75rem;
        gap: 5px;
        flex-wrap: wrap;
    }
    
    .timer-icon {
        font-size: 0.9rem;
    }
    
    .timer-label {
        font-size: 0.7rem;
        white-space: normal;
        flex: 1 1 auto;
        min-width: 0;
        max-width: none;
        overflow: visible;
        text-overflow: clip;
        line-height: 1.3;
    }
    
    .timer-countdown {
        font-size: 0.9rem;
        flex-shrink: 0;
        font-weight: 700;
    }
    
    .btn-clear-timer {
        width: 20px;
        height: 20px;
        font-size: 0.8rem;
    }
}
