/* ==========================================================================
   Pet Log — Claude Brand Theme
   ========================================================================== */

:root {
    /* Claude Brand Palette */
    --claude-cream:     #FAF6F1;
    --claude-warm:      #F5EDE4;
    --claude-sand:      #E8DDD0;
    --claude-terracotta:#D97757;
    --claude-terra-dark:#C4613F;
    --claude-terra-glow:#E8956F;
    --claude-dark:      #1A1915;
    --claude-charcoal:  #2D2B27;
    --claude-muted:     #8A8378;
    --claude-light-muted:#B5AEA4;

    /* Functional */
    --bg:               var(--claude-cream);
    --surface:          #FFFFFF;
    --surface-raised:   #FFFCF8;
    --border:           #E0D8CD;
    --border-light:     #EDE7DD;
    --text:             var(--claude-charcoal);
    --text-muted:       var(--claude-muted);
    --accent:           var(--claude-terracotta);
    --accent-hover:     var(--claude-terra-dark);
    --accent-glow:      var(--claude-terra-glow);
    --danger:           #C0392B;
    --danger-hover:     #A93226;
    --success:          #27AE60;

    /* Spacing */
    --radius:           12px;
    --radius-sm:        8px;
    --radius-lg:        20px;

    /* Fonts */
    --font-display:     'Fraunces', Georgia, serif;
    --font-body:        'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;

    /* Transitions */
    --ease:             cubic-bezier(0.4, 0, 0.2, 1);
}

/* ==========================================================================
   Reset & Base
   ========================================================================== */

*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-body);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

/* ==========================================================================
   Layout
   ========================================================================== */

.app-wrapper {
    max-width: 960px;
    margin: 0 auto;
    padding: 24px 20px 80px;
}

/* ==========================================================================
   Header
   ========================================================================== */

.app-header {
    margin-bottom: 32px;
}

.header-inner {
    display: flex;
    align-items: center;
}

.avatar-section {
    display: flex;
    align-items: center;
    gap: 20px;
}

.avatar-frame {
    width: 96px;
    height: 96px;
    border-radius: 50%;
    overflow: hidden;
    border: 3px solid var(--claude-sand);
    cursor: pointer;
    transition: border-color 0.3s var(--ease), transform 0.3s var(--ease), box-shadow 0.3s var(--ease);
    flex-shrink: 0;
    position: relative;
}

.avatar-frame:hover {
    border-color: var(--accent);
    transform: scale(1.05);
    box-shadow: 0 8px 32px rgba(217, 119, 87, 0.2);
}

.avatar-frame img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.avatar-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--claude-warm);
    color: var(--text-muted);
    gap: 2px;
}

.avatar-placeholder span {
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}

.header-text h1 {
    font-family: var(--font-display);
    font-size: 2.25rem;
    font-weight: 700;
    color: var(--claude-dark);
    line-height: 1.1;
    letter-spacing: -0.02em;
}

.header-text .subtitle {
    font-size: 0.95rem;
    color: var(--text-muted);
    margin-top: 4px;
    font-weight: 500;
}

/* ==========================================================================
   Quick Actions
   ========================================================================== */

.quick-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 28px;
    flex-wrap: wrap;
}

.quick-label {
    font-size: 0.82rem;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.quick-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 18px;
    border: 2px solid var(--border);
    border-radius: 100px;
    background: var(--surface);
    color: var(--text);
    font-family: var(--font-body);
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s var(--ease);
    white-space: nowrap;
}

.quick-btn svg {
    width: 14px;
    height: 14px;
    opacity: 0.5;
    transition: opacity 0.2s;
}

.quick-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: rgba(217, 119, 87, 0.06);
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(217, 119, 87, 0.12);
}

.quick-btn:hover svg {
    opacity: 1;
    stroke: var(--accent);
}

.quick-btn:active {
    transform: translateY(0);
}

/* ==========================================================================
   Form
   ========================================================================== */

.form-section {
    background: var(--surface);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: 28px;
    margin-bottom: 32px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

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

.form-header h2 {
    font-family: var(--font-display);
    font-size: 1.35rem;
    font-weight: 600;
    color: var(--claude-dark);
}

.btn-toggle-form {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.25s var(--ease);
}

.btn-toggle-form:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: rgba(217, 119, 87, 0.06);
}

.btn-toggle-form.collapsed svg {
    transform: rotate(45deg);
}

.pet-form {
    transition: all 0.3s var(--ease);
}

.pet-form.hidden {
    display: none;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 20px;
}

.form-group.full-width {
    grid-column: 1 / -1;
}

.form-group label {
    display: block;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.form-group input[type="date"],
.form-group input[type="time"],
.form-group textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: var(--font-body);
    font-size: 0.92rem;
    color: var(--text);
    background: var(--surface-raised);
    transition: border-color 0.25s var(--ease), box-shadow 0.25s var(--ease);
    outline: none;
}

.form-group textarea {
    resize: vertical;
    min-height: 48px;
}

.form-group input:focus,
.form-group textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(217, 119, 87, 0.12);
}

/* File input */
.file-input-wrapper {
    position: relative;
    border: 1.5px dashed var(--border);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    cursor: pointer;
    transition: border-color 0.25s var(--ease), background 0.25s var(--ease);
    background: var(--surface-raised);
}

.file-input-wrapper:hover {
    border-color: var(--accent);
    background: rgba(217, 119, 87, 0.03);
}

.file-input-wrapper input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.file-label {
    font-size: 0.88rem;
    color: var(--text-muted);
    pointer-events: none;
}

.file-label.has-file {
    color: var(--accent);
    font-weight: 500;
}

/* Actions */
.form-actions {
    display: flex;
    gap: 12px;
    align-items: center;
}

/* ==========================================================================
   Buttons
   ========================================================================== */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 24px;
    border-radius: var(--radius-sm);
    font-family: var(--font-body);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.25s var(--ease);
    white-space: nowrap;
}

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

.btn-primary:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 20px rgba(217, 119, 87, 0.3);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
    border: 1.5px solid var(--border);
    padding: 9px 20px;
}

.btn-ghost:hover {
    border-color: var(--text-muted);
    color: var(--text);
}

/* ==========================================================================
   Records Table
   ========================================================================== */

.records-section {
    background: var(--surface);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: 28px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.records-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    gap: 16px;
    flex-wrap: wrap;
}

.records-header h2 {
    font-family: var(--font-display);
    font-size: 1.35rem;
    font-weight: 600;
    color: var(--claude-dark);
}

.search-box {
    display: flex;
    align-items: center;
    gap: 8px;
    border: 1.5px solid var(--border);
    border-radius: 100px;
    padding: 8px 16px;
    background: var(--surface-raised);
    min-width: 220px;
    transition: border-color 0.25s var(--ease);
}

.search-box:focus-within {
    border-color: var(--accent);
}

.search-box svg {
    color: var(--text-muted);
    flex-shrink: 0;
}

.search-box input {
    border: none;
    background: transparent;
    outline: none;
    font-family: var(--font-body);
    font-size: 0.88rem;
    color: var(--text);
    width: 100%;
}

.search-box input::placeholder {
    color: var(--claude-light-muted);
}

/* Table */
.table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

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

.records-table thead th {
    text-align: left;
    padding: 10px 14px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}

.records-table tbody tr {
    border-bottom: 1px solid var(--border-light);
    transition: background 0.15s;
}

.records-table tbody tr:hover {
    background: rgba(217, 119, 87, 0.03);
}

.records-table tbody tr:last-child {
    border-bottom: none;
}

.records-table td {
    padding: 14px;
    font-size: 0.9rem;
    vertical-align: top;
    max-width: 240px;
}

.records-table td.what-cell {
    font-weight: 600;
    color: var(--claude-dark);
}

.records-table td.id-cell {
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--claude-light-muted);
    white-space: nowrap;
    width: 50px;
}

.records-table td.date-cell {
    white-space: nowrap;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

.records-table td.time-cell {
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.records-table td.note-cell {
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* Attachment link */
.attachment-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: var(--accent);
    text-decoration: none;
    font-size: 0.82rem;
    font-weight: 500;
    transition: color 0.2s;
}

.attachment-link:hover {
    color: var(--accent-hover);
    text-decoration: underline;
}

.attachment-thumb {
    width: 40px;
    height: 40px;
    border-radius: 6px;
    object-fit: cover;
    border: 1px solid var(--border-light);
}

/* Actions column */
.actions-col {
    width: 100px;
    text-align: center;
}

/* Checkbox column */
.check-col {
    width: 40px;
    text-align: center;
}

.check-col input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--accent);
    cursor: pointer;
}

/* Bulk delete bar */
.bulk-bar {
    display: none;
    align-items: center;
    justify-content: space-between;
    padding: 12px 18px;
    margin-bottom: 16px;
    background: #FDF0EB;
    border: 1.5px solid var(--claude-terra-glow);
    border-radius: var(--radius-sm);
    animation: fadeInUp 0.25s var(--ease);
}

.bulk-bar.visible {
    display: flex;
}

.bulk-count {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--claude-terra-dark);
}

.btn-danger {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 18px;
    border-radius: var(--radius-sm);
    font-family: var(--font-body);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    background: var(--danger);
    color: #fff;
    transition: all 0.25s var(--ease);
}

.btn-danger:hover {
    background: var(--danger-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(192, 57, 43, 0.25);
}

.btn-danger:active {
    transform: translateY(0);
}

.row-actions {
    display: flex;
    gap: 6px;
    justify-content: center;
}

.row-actions button {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s var(--ease);
    color: var(--text-muted);
}

.row-actions .btn-edit:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: rgba(217, 119, 87, 0.06);
}

.row-actions .btn-delete:hover {
    border-color: var(--danger);
    color: var(--danger);
    background: rgba(192, 57, 43, 0.06);
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--claude-light-muted);
    display: none;
}

.empty-state svg {
    margin-bottom: 16px;
    opacity: 0.4;
}

.empty-state p {
    font-size: 0.95rem;
    font-weight: 500;
}

.empty-state.visible {
    display: block;
}

/* ==========================================================================
   Toast
   ========================================================================== */

.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--claude-dark);
    color: #fff;
    padding: 12px 28px;
    border-radius: 100px;
    font-family: var(--font-body);
    font-size: 0.88rem;
    font-weight: 500;
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
    opacity: 0;
    transition: all 0.4s var(--ease);
    z-index: 1000;
    pointer-events: none;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ==========================================================================
   Animations
   ========================================================================== */

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.records-table tbody tr {
    animation: fadeInUp 0.3s var(--ease) both;
}

.records-table tbody tr:nth-child(1) { animation-delay: 0.02s; }
.records-table tbody tr:nth-child(2) { animation-delay: 0.04s; }
.records-table tbody tr:nth-child(3) { animation-delay: 0.06s; }
.records-table tbody tr:nth-child(4) { animation-delay: 0.08s; }
.records-table tbody tr:nth-child(5) { animation-delay: 0.10s; }

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 768px) {
    .app-wrapper {
        padding: 16px 14px 60px;
    }

    .avatar-frame {
        width: 72px;
        height: 72px;
    }

    .header-text h1 {
        font-size: 1.65rem;
    }

    .form-section,
    .records-section {
        padding: 20px 16px;
        border-radius: var(--radius);
    }

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

    .quick-actions {
        gap: 8px;
    }

    .quick-btn {
        padding: 7px 14px;
        font-size: 0.82rem;
    }

    .search-box {
        min-width: 100%;
    }

    .records-table td {
        padding: 10px 8px;
        font-size: 0.82rem;
    }

    .records-table thead th {
        padding: 8px;
        font-size: 0.7rem;
    }
}

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

    .avatar-section {
        gap: 14px;
    }

    .avatar-frame {
        width: 60px;
        height: 60px;
    }

    .header-text h1 {
        font-size: 1.4rem;
    }
}
