/* --- 1. FONT IMPORT & GLOBAL STYLES --- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;700&display=swap');

:root {
    --bg-light: #eeeeee;
    --bg-medium: #cccccc;
    --text-dark: #333333;
    --text-medium: #555555;
    --text-light: #9a9a9a;
    --font-primary: 'Inter', sans-serif;
}

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

body {
    font-family: var(--font-primary);
    background-color: var(--bg-light);
    color: var(--text-dark);
    line-height: 1.6;
}

/* --- 2. LAYOUT & CONTAINER STYLES --- */
.app-container {
    max-width: 960px;
    /* Adjusted for a more focused content area */
    margin: 0 auto;
    padding: 2rem 1rem;
}

.app-header {
    background-color: #555555;
    position: sticky;
    top: 0;
    z-index: 10;
    transition: background-color 0.3s ease;
}

.app-header.scrolled {
    background-color: rgba(85, 85, 85, 0.7);
}

.header-container {
    max-width: 960px;
    margin: 0 auto;
    display: flex;
    padding: 1.25rem 1rem;
    justify-content: space-between;
    align-items: center;
}

.logo {
    height: 45px;
}

.search-toggle-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.search-toggle-btn svg {
    stroke: white;
    width: 52px;
    height: 52px;
}


/* --- 3. CONTROLS PANEL --- */
.controls-panel {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 2.5rem;
}

.search-container {
    width: 100%;
}

.filter-row {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

/* Base styles for input */
#search-input {
    width: 100%;
    padding: 0.75rem;
    font-size: 1rem;
    border: 1px solid var(--bg-medium);
    border-radius: 6px;
    background-color: #fff;
}

/* --- Custom Select Dropdown --- */
.custom-select {
    position: relative;
    width: 100%;
    font-size: 1rem;
}

.select-selected {
    background-color: #fff;
    padding: 0.75rem 2.5rem 0.75rem 0.75rem;
    border: 1px solid var(--bg-medium);
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    user-select: none;
}

.select-selected.select-arrow-active .select-arrow {
    transform: rotate(180deg);
}

.select-arrow {
    width: 20px;
    height: 20px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%23333333' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
    transition: transform 0.2s ease;
    position: absolute;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
}

.select-items {
    position: absolute;
    background-color: #fff;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    z-index: 99;
    border: 1px solid var(--bg-medium);
    border-radius: 6px;
    max-height: 75vh;
    overflow-y: auto;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.select-hide {
    display: none;
}

.select-items div {
    padding: 0.75rem;
    cursor: pointer;
    border-bottom: 1px solid var(--bg-light);
}

.select-items div:last-child {
    border-bottom: none;
}

.select-items div:hover,
.same-as-selected {
    background-color: #f0f0f0;
}

/* Favourites filter button in header */
.favourites-filter-btn {
    flex-shrink: 0;
    width: 46px;
    height: 46px;
    padding: 0.65rem;
    background-color: #fff;
    border: 1px solid var(--bg-medium);
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    color: #999999;
}

.favourites-filter-btn:hover {
    background-color: #f5f5f5;
}

.favourites-filter-btn.active {
    background-color: #DC143C;
    border-color: #DC143C;
    color: #ffffff;
}

.favourites-filter-btn svg {
    width: 24px;
    height: 24px;
}

.hidden {
    display: none;
}

/* --- 4. PROMPT LIST & CARDS --- */
/* .prompt-list-container {
    display: grid;
    gap: 1.5rem;
} */

/* --- 4. PROMPT LIST & CARDS (NEW STRUCTURE) --- */
.category-group+.category-group {
    margin-top: 3rem;
    /* Space between major category groups */
}

.category-title {
    /* "Clean & Minimal" style */
    font-size: 1.8rem;
    font-weight: 700;
    color: #555555;
    text-align: center;
    margin-bottom: 1rem;
}

.subcategory-card {
    background-color: #ffffff;
    border: 1px solid var(--bg-medium);
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
    margin-bottom: 1.5rem;
    /* Space between cards in the same category */
}

.subcategory-title-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--bg-light);
}

.subcategory-title {
    font-size: 1.3rem;
    color: var(--text-medium);
    margin: 0;
}

.task-item+.task-item {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--bg-light);
}

.task-label {
    color: var(--text-dark);
    margin-right: 0.5rem;
}

.task-item p {
    color: var(--text-medium);
    margin-bottom: 1rem;
}

/* Action buttons container */
.action-buttons {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    margin-top: 1rem;
}

/* Base styles for all action buttons */
.action-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    color: #999999;
}

.action-btn:hover {
    transform: scale(1.1);
}

.action-btn svg {
    width: 24px;
    height: 24px;
}

/* Subcategory favourite button states */
.subcategory-favourite-btn svg {
    stroke: currentColor;
    stroke-width: 2.0;
}

.subcategory-favourite-btn.active {
    color: #DC143C;
}

.subcategory-favourite-btn.active svg {
    fill: #DC143C;
    stroke: #DC143C;
}

/* Copy button states */
.copy-btn svg {
    stroke-width: 1.5;
}

.copy-btn.copied {
    color: #4f0388;
    animation: pulse-animation 0.4s ease-in-out;
}

/* Adds animation to copy button */
@keyframes pulse-animation {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.2);
    }

    100% {
        transform: scale(1);
    }
}

/* Back to top button */
.back-to-top-btn {
    color: #999999;
}

.back-to-top-btn:hover {
    color: #999999;
}

.back-to-top-btn svg {
    stroke-width: 2;
}

/* --- 5. FOOTER --- */
.app-footer {
    background-color: #555555;
    /* Same as header */
    color: white;
    text-align: center;
    padding: 1.5rem;
    margin-top: 3rem;
    /* Pushes footer away from the content */
}

.app-footer p {
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.8);
    font-weight: 400;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin: 0;
}

.app-footer svg {
    fill: none;
    stroke: white;
    stroke-width: 1px;
    stroke-linecap: round;
    stroke-linejoin: round;
    width: 18px;
    height: 18px;
}

/* --- 6. MEDIA QUERIES --- */
@media (max-width: 768px) {
    .app-container {
        /* Increase side padding for more breathing room on mobile */
        padding: 2rem 1.5rem;
    }

    .header-container {
        padding: 1rem 1.5rem;
        /* Match the new app-container padding */
    }

    .logo {
        height: 35px;
    }

    .search-toggle-btn svg {
        width: 24px;
        height: 24px;
    }
}

/* --- 7. SPLASH SCREEN --- */
#splash-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: linear-gradient(135deg, #8A2BE2 0%, #4B0082 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    padding: 2rem;
}

.splash-content {
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
    align-items: center;
    text-align: center;
}

.splash-main-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    max-width: 320px;
    /* Control max width of content */
}

.splash-logo {
    width: 300px;
    height: auto;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.3));
    margin-bottom: 1.5rem;
}

.splash-text {
    font-size: 1.2rem;
    color: #FFFFFF;
    margin: 0;
    font-weight: 400;
    line-height: 1.4;
}

#enter-app-btn {
    background: #FFD700;
    color: #000000;
    border: none;
    padding: 1rem 2rem;
    border-radius: 8px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-top: 1.5rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

#enter-app-btn:hover {
    background: #FFC107;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3);
}


/* Mobile adjustments */
@media (max-width: 480px) {
    #splash-screen {
        padding: 2rem;
    }

    .splash-logo {
        width: 200px;
    }

    .splash-text {
        font-size: 1rem;
    }

    #enter-app-btn {
        padding: 0.875rem 1.5rem;
        font-size: 1rem;
    }
}

/* --- 8. EDIT DRAWER --- */
.edit-drawer-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 2000;
    transition: opacity 0.3s ease;
}

.edit-drawer-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.edit-drawer {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: var(--bg-light);
    z-index: 2100;
    display: flex;
    flex-direction: column;
    transform: translateY(100%);
    transition: transform 0.3s ease-out;
}

.edit-drawer.hidden {
    transform: translateY(100%);
    pointer-events: none;
}

.edit-drawer.open {
    transform: translateY(0);
}

.edit-drawer-content {
    flex: 1;
    max-width: 960px;
    /* ☝️ Matches app-container max-width to prevent width jump on desktop */
    margin: 0 auto;
    width: 100%;
    padding: 2rem 1rem;
    /* ☝️ Controls MARGIN OUTSIDE textarea (top/bottom left/right) */
    display: flex;
    flex-direction: column;
    gap: 1rem;
    /* ☝️ Controls space BETWEEN icon row and textarea (reduce this to bring them closer) */
}

.edit-drawer-actions {
    display: flex;
    justify-content: space-between;
    /* ☝️ Share/Copy left, Close right */
    gap: 1rem;
    align-items: center;
}

.edit-drawer-actions-left {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.edit-drawer-icon-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #555555;
    transition: all 0.2s ease;
}

.edit-drawer-icon-btn:hover {
    transform: scale(1.1);
}

.edit-drawer-icon-btn.copied {
    color: #4f0388;
    animation: pulse-animation 0.4s ease-in-out;
}

.edit-drawer-icon-btn svg {
    width: 24px;
    height: 24px;
}

.edit-drawer-textarea {
    width: 100%;
    flex: 1;
    padding: 1.5rem;
    /* ☝️ Controls PADDING INSIDE textarea (between border and text) */
    font-size: 16px;
    /* ☝️ Changed from 1rem to 16px - prevents Android auto-zoom on textareas */
    line-height: 1.6;
    font-family: var(--font-primary);
    color: var(--text-dark);
    background-color: #ffffff;
    border: 1px solid var(--bg-medium);
    border-radius: 6px;
    resize: none;
    outline: none;
    -webkit-text-size-adjust: 100%;
    /* ☝️ Prevents browser auto-adjusting font size on some Android devices */
}

.edit-drawer-textarea:focus {
    border-color: var(--bg-medium);
}

.edit-drawer-textarea::placeholder {
    color: var(--text-light);
}

.edit-drawer-textarea::selection {
    background-color: rgba(85, 85, 85, 0.3);
    /* ☝️ Custom grey selection instead of default blue */
    color: #333333;
}

.edit-drawer-textarea::-webkit-selection {
    background-color: rgba(85, 85, 85, 0.3);
    color: #333333;
}

.edit-drawer-textarea::-moz-selection {
    background-color: rgba(85, 85, 85, 0.3);
    color: #333333;
}

/* --- 8B. BRACKET SELECTION TOOLTIP --- */
.bracket-tooltip {
    position: fixed;
    background-color: rgba(85, 85, 85, 0.95);
    color: #ffffff;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    min-width: 260px;
    /* ☝️ Ensures tooltip is wide enough for 2-line layout */
    max-width: 280px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    z-index: 2200;
    opacity: 0;
    transform: translateY(-10px);
    transition: opacity 0.2s ease, transform 0.2s ease;
    pointer-events: none;
}

.bracket-tooltip.show {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.bracket-tooltip.hidden {
    display: none;
}

.bracket-tooltip-close {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    transition: opacity 0.2s ease;
    opacity: 0.7;
}

.bracket-tooltip-close:hover {
    opacity: 1;
}

.bracket-tooltip-close svg {
    width: 14px;
    height: 14px;
}

.bracket-tooltip-content {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    padding-right: 1.5rem;
}

.bracket-tooltip-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    stroke: #ffffff;
    /* White info icon */
}

.bracket-tooltip p {
    margin: 0;
    font-size: 0.9rem;
    line-height: 1.4;
}

/* Mobile adjustments for edit drawer */
@media (max-width: 768px) {
    .edit-drawer-content {
        padding-top: max(2rem, env(safe-area-inset-top));
        /* ☝️ Respects notch/status bar on iPhone, prevents button cut-off */
        padding-bottom: max(2rem, env(safe-area-inset-bottom));
        padding-left: max(1.5rem, env(safe-area-inset-left));
        padding-right: max(1.5rem, env(safe-area-inset-right));
    }

    .bracket-tooltip {
        max-width: 240px;
        font-size: 0.85rem;
    }
}

/* --- 9. TOOLTIP --- */
.tooltip-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1050;
}

.tooltip {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: #e6e2fff2;
    color: #000000;
    padding: 1.5rem;
    border-radius: 12px;
    max-width: 320px;
    width: 80%;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
    border: 1px solid #cccccc;
    z-index: 1100;
    animation: tooltipFadeIn 0.3s ease-out;
}

@keyframes tooltipFadeIn {
    from {
        opacity: 0;
        transform: translate(-50%, -45%);
    }

    to {
        opacity: 1;
        transform: translate(-50%, -50%);
    }
}

.tooltip-content {
    position: relative;
}

.tooltip-text-area {
    min-height: 90px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.tooltip-text-area h3 {
    margin-top: 0;
    margin-bottom: 0.75rem;
    font-size: 1.2rem;
    color: #333;
    text-align: center;
}

.tooltip-text-area p {
    margin-top: 0;
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
    font-weight: 700;
    line-height: 1.5;
    color: #333;
    text-align: center;
}

.tooltip-close {
    position: absolute;
    top: -10px;
    right: -10px;
    background-color: #555;
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    font-size: 22px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s ease;
    z-index: 1;
}

.tooltip-close:hover {
    background-color: #000;
}

.tooltip-close svg {
    width: 16px;
    height: 16px;
}

.tooltip-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 1rem;
}

.tooltip-progress-dots {
    display: flex;
    gap: 6px;
    flex-grow: 1;
    justify-content: center;
}

.tooltip-progress-dots .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #888888;
    transition: background-color 0.3s;
}

.tooltip-progress-dots .dot.active {
    background-color: #555555;
}

.tooltip-arrow-btn {
    background: none;
    border: none;
    padding: 0;
    margin: 0;
    cursor: pointer;
    font-size: 32px;
    line-height: 1;
    transition: all 0.2s ease-in-out;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.tooltip-arrow-btn svg {
    width: 36px;
    height: 36px;
    fill: #ffffff;
}

.tooltip-arrow-btn:not(.inactive) {
    background-color: #4f0388;
}

.tooltip-arrow-btn:hover:not(.inactive) {
    background-color: #4f0388;
}

.tooltip-arrow-btn.inactive {
    background-color: transparent;
    cursor: default;
}

.tooltip-arrow-btn.inactive svg {
    fill: #777777;
}