/**
 * Coffee App - The Morning Ritual
 * Warm, crafty, inviting. Like a neighborhood coffee shop menu board.
 * @version 10.0.0
 */

/* =============================================================================
   THEME VARIABLES
   ============================================================================= */

.app-coffee {
    --coffee-accent: #6F4E37;
    --coffee-accent-hover: #5C3A1E;
    --coffee-accent-light: #8B7355;
    --coffee-star: #E8A838;
    --coffee-border: rgb(111 78 55 / 12%);
    --coffee-tint: rgb(111 78 55 / 5%);
    --app-star: var(--coffee-star);
}

/* =============================================================================
   BASE LAYOUT
   ============================================================================= */

.coffee-main {
    min-height: 100vh;
    background-color: #FAF7F4;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 80px 20px 40px;
}

.coffee-container {
    background: linear-gradient(180deg, #FFFAF5 0%, #F5E8D8 100%);
    border-radius: 20px;
    box-shadow: 0 4px 24px rgb(111 78 55 / 8%);
    border: 1px solid var(--coffee-border);
    padding: 36px 28px 32px;
    width: 100%;
    max-width: 420px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

/* =============================================================================
   TWO-COLUMN LAYOUT
   ============================================================================= */

.coffee-layout {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.coffee-library-column {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    width: 100%;
}

.coffee-form-column {
    width: 100%;
}

/* =============================================================================
   GREETING HEADER
   ============================================================================= */

.coffee-greeting {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.coffee-icon {
    font-size: 48px;
    line-height: 1;
}

.coffee-greeting-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--coffee-accent);
    letter-spacing: -0.3px;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

@keyframes slideUpFromBottom {
    from { opacity: 0; transform: translateY(100%); }
    to { opacity: 1; transform: translateY(0); }
}

/* =============================================================================
   DELETE CONFIRMATION DIALOG
   ============================================================================= */

.delete-dialog-backdrop {
    position: fixed;
    inset: 0;
    background: rgb(0 0 0 / 40%);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: fadeIn 0.15s ease;
}

.delete-dialog {
    background: #FFFAF5;
    border-radius: 18px;
    box-shadow: 0 8px 40px rgb(111 78 55 / 20%);
    border: 1px solid var(--coffee-border);
    padding: 24px;
    max-width: 300px;
    width: 100%;
    text-align: center;
    animation: slideUp 0.2s ease;
}

.delete-dialog-title {
    font-size: 16px;
    font-weight: 700;
    color: #333;
    margin-bottom: 8px;
}

.delete-dialog-body {
    font-size: 13px;
    color: var(--coffee-accent-light);
    margin-bottom: 20px;
}

.delete-dialog-actions {
    display: flex;
    gap: 10px;
}

.delete-dialog-btn {
    flex: 1;
    padding: 12px;
    font-size: 14px;
    font-weight: 600;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.15s ease;
    -webkit-tap-highlight-color: transparent;
}

.delete-dialog-btn--cancel {
    color: var(--coffee-accent-light);
    background: transparent;
    border: 1.5px solid rgb(111 78 55 / 15%);
}

.delete-dialog-btn--cancel:hover {
    background: var(--coffee-tint);
    border-color: var(--coffee-accent);
    color: var(--coffee-accent);
}

.delete-dialog-btn--confirm {
    color: white;
    background: #EF4444;
    border: none;
    box-shadow: 0 2px 8px rgb(239 68 68 / 25%);
}

.delete-dialog-btn--confirm:hover {
    background: #DC2626;
    box-shadow: 0 4px 12px rgb(239 68 68 / 35%);
}

@media (max-width: 480px) {
    .delete-dialog-backdrop {
        align-items: flex-end;
        padding: 0;
    }

    .delete-dialog {
        max-width: 100%;
        border-radius: 18px 18px 0 0;
        padding: 24px 24px calc(20px + env(safe-area-inset-bottom, 0px));
        animation: slideUpFromBottom 0.25s ease;
    }
}

/* =============================================================================
   FORM SECTION (collapsible)
   ============================================================================= */

.form-section {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding-top: 4px;
    border-top: 1.5px solid rgb(111 78 55 / 10%);
}

.form-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.form-section-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--coffee-accent);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-section-close {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    color: var(--coffee-accent-light);
    background: transparent;
    border: 1px solid rgb(111 78 55 / 12%);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s ease;
    -webkit-tap-highlight-color: transparent;
    margin: -8px -8px -8px 0;
}

.form-section-close:hover {
    background: var(--coffee-tint);
    border-color: var(--coffee-accent);
    color: var(--coffee-accent);
}

/* =============================================================================
   INPUT SECTIONS
   ============================================================================= */

.input-section {
    width: 100%;
}

.input-label {
    display: block;
    font-size: 12px;
    font-weight: 700;
    color: var(--coffee-accent-light);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
}

.coffee-input {
    width: 100%;
    padding: 13px 18px;
    font-size: 16px;
    border: 1.5px solid var(--coffee-border);
    border-radius: 12px;
    background: var(--color-neutral-0);
    color: var(--color-text-primary);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.coffee-input:focus {
    outline: none;
    border-color: var(--coffee-accent);
    box-shadow: 0 0 0 3px rgb(111 78 55 / 8%);
    background: var(--color-neutral-0);
}

.coffee-input::placeholder {
    color: var(--color-neutral-400);
}

/* Hide hint text — placeholders are enough */
.input-hint {
    display: none;
}

/* =============================================================================
   ROAST SELECTION
   ============================================================================= */

.roast-chip {
    padding: 8px 18px;
    font-size: 13px;
    font-weight: 600;
    color: var(--coffee-accent-light);
    background: var(--coffee-tint);
    border: 1.5px solid rgb(111 78 55 / 15%);
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}

.roast-chip:hover {
    background: rgb(111 78 55 / 10%);
    border-color: var(--coffee-accent);
    color: var(--coffee-accent);
}

.roast-chip.selected {
    background: var(--coffee-accent);
    border-color: var(--coffee-accent);
    color: white;
}

/* =============================================================================
   STAR RATING
   ============================================================================= */

.rating-section {
    width: 100%;
    text-align: center;
}

.rating-label {
    font-size: 12px;
    font-weight: 700;
    color: var(--coffee-accent-light);
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
}

.star-rating {
    display: flex;
    justify-content: center;
    gap: 8px;
}

.star {
    width: 44px;
    height: 44px;
    font-size: 24px;
    color: #d4d0cc;
    background: var(--coffee-tint);
    border: 1.5px solid rgb(111 78 55 / 12%);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.15s ease;
    -webkit-tap-highlight-color: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
}

.star:hover {
    color: var(--coffee-star);
    border-color: var(--coffee-star);
    background: rgb(232 168 56 / 8%);
}

.star.selected {
    color: var(--coffee-star);
    border-color: var(--coffee-star);
    background: rgb(232 168 56 / 10%);
}

/* =============================================================================
   ACTION BUTTONS
   ============================================================================= */

.action-buttons {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    width: 100%;
}

.log-button {
    width: 100%;
    padding: 16px;
    font-size: 16px;
    font-weight: 600;
    color: white;
    background: var(--coffee-accent);
    border: none;
    border-radius: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 12px rgb(111 78 55 / 20%);
    -webkit-tap-highlight-color: transparent;
}

.log-button:hover:not(:disabled) {
    background: var(--coffee-accent-hover);
    box-shadow: 0 4px 16px rgb(111 78 55 / 28%);
    transform: translateY(-1px);
}

.log-button:active:not(:disabled) {
    transform: translateY(0);
}

.log-button:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.cancel-button {
    padding: 10px 24px;
    font-size: 14px;
    font-weight: 500;
    color: var(--coffee-accent-light);
    background: transparent;
    border: 1.5px solid rgb(111 78 55 / 15%);
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.cancel-button:hover {
    background: var(--coffee-tint);
    border-color: var(--coffee-accent);
    color: var(--coffee-accent);
}

/* =============================================================================
   TODAY'S COUNT
   ============================================================================= */

.today-count {
    font-size: 15px;
    font-weight: 600;
    color: var(--coffee-accent);
    padding: 12px 24px;
    background: rgb(255 255 255 / 60%);
    border-radius: 14px;
    border: 1.5px solid rgb(111 78 55 / 12%);
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    justify-content: center;
}

.today-count__icon {
    font-size: 20px;
    line-height: 1;
}

/* =============================================================================
   RESPONSIVE
   ============================================================================= */

@media (max-width: 480px) {
    .coffee-main {
        padding: 76px 16px 32px;
    }

    .coffee-container {
        padding: 20px 20px 24px;
        gap: 14px;
        border-radius: 16px;
    }

    .coffee-greeting {
        flex-direction: row;
        gap: 8px;
    }

    .coffee-icon {
        font-size: 28px;
    }

    .star {
        width: 44px;
        height: 44px;
        font-size: 20px;
    }

    .log-button {
        border-radius: 12px;
        padding: 14px;
    }
}

@media (min-width: 768px) {
    .coffee-container {
        max-width: 780px;
        padding: 32px;
        border-radius: 24px;
        align-items: stretch;
    }

    .coffee-layout {
        flex-direction: row;
        align-items: flex-start;
        gap: 28px;
    }

    .coffee-library-column {
        flex: 1;
        min-width: 0;
    }

    .coffee-form-column {
        flex: 0 0 300px;
        position: sticky;
        top: 100px;
    }

    /* On desktop, show form always and remove close button */
    .coffee-form-column .form-section {
        display: flex !important;
        border-top: none;
        background: rgb(255 255 255 / 50%);
        border: 1.5px solid var(--coffee-border);
        border-radius: 16px;
        padding: 24px 20px;
    }

    .coffee-form-column .form-section-close {
        display: none;
    }
}

@media (min-width: 1024px) {
    .coffee-container {
        max-width: 880px;
        padding: 40px;
    }

    .coffee-layout {
        gap: 36px;
    }

    .coffee-form-column {
        flex: 0 0 340px;
    }
}

/* =============================================================================
   SELECT DROPDOWNS
   ============================================================================= */

.coffee-select {
    width: 100%;
    padding: 13px 18px;
    font-size: 16px;
    font-family: inherit;
    border: 1.5px solid var(--coffee-border);
    border-radius: 12px;
    background: var(--color-neutral-0);
    color: var(--color-text-primary);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%238B7355' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
    padding-right: 40px;
    cursor: pointer;
}

.coffee-select:focus {
    outline: none;
    border-color: var(--coffee-accent);
    box-shadow: 0 0 0 3px rgb(111 78 55 / 8%);
}

.coffee-select:invalid,
.coffee-select option[value=""][disabled] {
    color: var(--color-neutral-400);
}

.coffee-select--dialog {
    padding: 10px 14px;
    font-size: 14px;
    border-radius: 10px;
}

/* =============================================================================
   MANAGE SECTIONS (Equipment & Coffees)
   ============================================================================= */

.manage-section {
    width: 100%;
    border-top: 1.5px solid rgb(111 78 55 / 10%);
    padding-top: 12px;
    margin-top: 4px;
}

.manage-toggle {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 4px;
    background: transparent;
    border: none;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.manage-toggle-text {
    font-size: 13px;
    font-weight: 700;
    color: var(--coffee-accent);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.manage-toggle-count {
    font-size: 11px;
    font-weight: 600;
    color: var(--coffee-accent-light);
    background: var(--coffee-tint);
    border: 1px solid rgb(111 78 55 / 10%);
    border-radius: 10px;
    padding: 1px 7px;
    line-height: 1.4;
}

.manage-toggle-icon {
    font-size: 10px;
    color: var(--coffee-accent-light);
    margin-left: auto;
    transition: transform 0.15s ease;
}

.manage-list {
    display: none;
    flex-direction: column;
    gap: 4px;
    padding: 0 4px;
}

.manage-list.expanded {
    display: flex;
}

.manage-empty {
    font-size: 12px;
    color: var(--coffee-accent-light);
    padding: 8px 0;
    text-align: center;
}

.manage-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    border-radius: 10px;
    background: rgb(255 255 255 / 50%);
    border: 1px solid rgb(111 78 55 / 8%);
}

.manage-item-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    object-fit: cover;
    flex-shrink: 0;
}

.manage-item-icon--placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    background: var(--coffee-tint);
    border: 1px solid rgb(111 78 55 / 10%);
}

.manage-item-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--color-text-primary);
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.manage-item-roast {
    font-size: 11px;
    font-weight: 600;
    color: var(--coffee-accent-light);
    background: var(--coffee-tint);
    padding: 2px 8px;
    border-radius: 10px;
    flex-shrink: 0;
}

.manage-item-edit {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    color: var(--coffee-accent-light);
    background: transparent;
    border: 1px solid rgb(111 78 55 / 10%);
    border-radius: 8px;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.15s ease;
    -webkit-tap-highlight-color: transparent;
}

.manage-item-edit:hover {
    color: var(--coffee-accent);
    border-color: var(--coffee-accent);
    background: var(--coffee-tint);
}

.manage-item-delete {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    color: var(--coffee-accent-light);
    background: transparent;
    border: 1px solid rgb(111 78 55 / 10%);
    border-radius: 8px;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.15s ease;
    -webkit-tap-highlight-color: transparent;
}

.manage-item-delete:hover {
    color: #EF4444;
    border-color: #EF4444;
    background: rgb(239 68 68 / 5%);
}

/* Add form */
.manage-add {
    padding: 8px 4px;
}

.manage-add-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.manage-photo-btn {
    width: 44px;
    height: 44px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1.5px dashed rgb(111 78 55 / 20%);
    border-radius: 10px;
    cursor: pointer;
    overflow: hidden;
    transition: border-color 0.15s ease;
    position: relative;
    -webkit-tap-highlight-color: transparent;
}

.manage-photo-btn:hover {
    border-color: var(--coffee-accent);
}

.manage-photo-input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    overflow: hidden;
}

.manage-photo-placeholder {
    font-size: 18px;
    line-height: 1;
}

.manage-photo-preview {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 8px;
}

.manage-name-input {
    flex: 1;
    min-width: 0;
    padding: 10px 14px;
    font-size: 14px;
    font-family: inherit;
    border: 1.5px solid var(--coffee-border);
    border-radius: 10px;
    background: var(--color-neutral-0);
    color: var(--color-text-primary);
    transition: border-color 0.15s ease;
}

.manage-name-input:focus {
    outline: none;
    border-color: var(--coffee-accent);
    box-shadow: 0 0 0 3px rgb(111 78 55 / 8%);
}

.manage-name-input::placeholder {
    color: var(--color-neutral-400);
}

.manage-save-btn {
    width: 44px;
    height: 44px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: 600;
    color: white;
    background: var(--coffee-accent);
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.15s ease;
    -webkit-tap-highlight-color: transparent;
}

.manage-save-btn:hover:not(:disabled) {
    background: var(--coffee-accent-hover);
}

.manage-save-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.manage-roast-section {
    padding: 6px 0 0;
    text-align: center;
}

.manage-roast-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--coffee-accent-light);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.6px;
}

.manage-roast-chips {
    display: flex;
    justify-content: center;
    gap: 6px;
}

.manage-roast-chips .roast-chip {
    padding: 5px 14px;
    font-size: 12px;
}

.manage-add-toggle {
    width: 100%;
    padding: 10px 4px;
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--coffee-accent-light);
    font-size: 13px;
    font-weight: 600;
    text-align: left;
    transition: color 0.15s ease;
    -webkit-tap-highlight-color: transparent;
}

.manage-add-toggle:hover {
    color: var(--coffee-accent);
}

/* =============================================================================
   HISTORY ITEM ICONS
   ============================================================================= */

.history-item-header {
    display: flex;
    align-items: center;
    gap: 6px;
}

.history-item-icon {
    width: 20px;
    height: 20px;
    border-radius: 4px;
    object-fit: cover;
    flex-shrink: 0;
}

.history-item-equipment {
    display: inline-flex;
    align-items: center;
    gap: 3px;
}

.history-item-micro-icon {
    width: 14px;
    height: 14px;
    border-radius: 3px;
    object-fit: cover;
}

/* =============================================================================
   REDUCED MOTION
   ============================================================================= */

@media (prefers-reduced-motion: reduce) {
    .coffee-input,
    .coffee-select,
    .roast-chip,
    .star,
    .log-button,
    .cancel-button,
    .form-section-close,
    .delete-dialog,
    .delete-dialog-backdrop,
    .manage-item-edit,
    .manage-item-delete,
    .manage-photo-btn,
    .manage-save-btn {
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
    }
}
