/* Prompts Builder Premium Dashboard Styles */

:root {
    --pb-primary: #3b82f6;
    /* Modern Blue */
    --pb-primary-dark: #2563eb;
    --pb-sidebar-bg: #0f172a;
    /* Slate 900 */
    --pb-sidebar-hover: #1e293b;
    --pb-bg: #f1f5f9;
    /* Slate 100 */
    --pb-card-bg: #ffffff;
    --pb-text-main: #1e293b;
    --pb-text-muted: #64748b;
    --pb-border: #e2e8f0;
    --pb-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --pb-radius: 12px;
}

/* --- Global Components --- */
.primary-btn {
    width: 100%;
    padding: 12px 24px;
    background: var(--pb-primary);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
    display: inline-block;
    text-align: center;
    text-decoration: none;
}

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

/* --- Auth Pages --- */
.prompts-auth-container {
    max-width: 420px;
    margin: 60px auto;
    background: var(--pb-card-bg);
    padding: 40px;
    border-radius: var(--pb-radius);
    box-shadow: var(--pb-shadow);
    border: 1px solid var(--pb-border);
    font-family: 'Inter', system-ui, sans-serif;
    position: relative;
    z-index: 10;
    /* Ensure it sits above background if needed */
}

.prompts-auth-container h3 {
    text-align: center;
    margin-bottom: 30px;
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--pb-text-main);
}

.prompts-form .form-group {
    margin-bottom: 20px;
}

.prompts-form label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    font-size: 0.95rem;
    color: var(--pb-text-main);
}

.prompts-form input[type="text"],
.prompts-form input[type="email"],
.prompts-form input[type="password"] {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--pb-border);
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.2s, box-shadow 0.2s;
    box-sizing: border-box;
    background: #fff;
}

.prompts-form input:focus {
    border-color: var(--pb-primary);
    outline: none;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.auth-link {
    text-align: center;
    margin-top: 24px;
    font-size: 0.95rem;
    color: var(--pb-text-muted);
}

.auth-link a {
    color: var(--pb-primary);
    text-decoration: none;
    font-weight: 500;
}

/* --- Aggressive Reset for Dashboard Wrapper --- */
.pb-app-container {
    display: flex !important;
    min-height: 100vh !important;
    background-color: var(--pb-bg) !important;
    font-family: 'Inter', system-ui, -apple-system, sans-serif !important;
    color: var(--pb-text-main);
    line-height: 1.5;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    z-index: 999999 !important;
    overflow: hidden !important;
    margin: 0 !important;
    padding: 0 !important;
}

.pb-app-container * {
    box-sizing: border-box;
}

/* --- Sidebar (30% but max 300px) --- */
.pb-sidebar {
    width: 280px;
    background-color: var(--pb-sidebar-bg);
    color: white;
    display: flex;
    flex-direction: column;
    border-right: 1px solid #334155;
    flex-shrink: 0;
}

.pb-brand {
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.pb-brand .dashicons {
    font-size: 28px;
    width: 28px;
    height: 28px;
    color: var(--pb-primary);
}

.pb-brand h2 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 700;
    color: white;
    letter-spacing: -0.025em;
}

.pb-brand .highlight {
    color: var(--pb-primary);
}

.pb-nav {
    flex: 1;
    padding: 24px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.pb-nav-item {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    color: #94a3b8;
    text-decoration: none;
    border-radius: 8px;
    transition: all 0.2s;
    font-weight: 500;
}

.pb-nav-item:hover,
.pb-nav-item.active {
    background-color: var(--pb-sidebar-hover);
    color: white;
}

.pb-nav-item .dashicons {
    margin-right: 12px;
    font-size: 20px;
}

.pb-user-card {
    padding: 20px;
    background: rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    gap: 12px;
}

.pb-avatar {
    width: 40px;
    height: 40px;
    background: var(--pb-primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: white;
}

.pb-user-info {
    display: flex;
    flex-direction: column;
}

.pb-username {
    font-weight: 600;
    font-size: 0.95rem;
    color: white;
}

.pb-userrole {
    font-size: 0.8rem;
    color: #94a3b8;
}

/* --- Main Content (70%) --- */
.pb-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

.pb-header {
    height: 70px;
    background: white;
    border-bottom: 1px solid var(--pb-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 32px;
    flex-shrink: 0;
}

.pb-header h1 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--pb-text-main);
}

.pb-profile-menu {
    display: flex;
    align-items: center;
    gap: 16px;
}

.pb-logout-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--pb-text-muted);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    padding: 8px 16px;
    border-radius: 20px;
    background: #f8fafc;
    transition: all 0.2s;
}

.pb-logout-btn:hover {
    background: #fee2e2;
    color: #ef4444;
}

.pb-content-area {
    flex: 1;
    overflow-y: auto;
    padding: 32px;
}

/* --- Sections --- */
/* --- Sections --- */
.pb-section {
    max-width: 1200px;
    margin: 0 auto;
    /* Visible by default as PHP handles rendering */
    display: block !important;
}

/* --- Library Grid --- */
#prompts-search {
    width: 100%;
    padding: 16px 24px;
    font-size: 1.1rem;
    border: 1px solid var(--pb-border);
    border-radius: 12px;
    margin-bottom: 24px;
    box-shadow: var(--pb-shadow);
    transition: all 0.2s;
}

#prompts-search:focus {
    outline: none;
    border-color: var(--pb-primary);
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.1);
}

.prompts-filters {
    margin-bottom: 32px;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.filter-btn {
    background: white;
    border: 1px solid var(--pb-border);
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--pb-text-muted);
    cursor: pointer;
    transition: all 0.2s;
}

.filter-btn:hover {
    background: #f8fafc;
    color: var(--pb-text-main);
}

.filter-btn.active {
    background: var(--pb-primary);
    color: white;
    border-color: var(--pb-primary);
}

.prompts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 24px;
}

.prompt-card {
    background: white;
    border: 1px solid var(--pb-border);
    border-radius: 16px;
    padding: 24px;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    display: flex;
    flex-direction: column;
}

.prompt-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1);
    border-color: #cbd5e1;
}

.prompt-card h3 {
    margin: 12px 0;
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--pb-text-main);
}

.card-tags {
    margin-top: auto;
    font-size: 0.85rem;
    color: var(--pb-text-muted);
}

/* --- Slide-over Drawer --- */
.pb-drawer-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    z-index: 999998;
}

.pb-drawer {
    position: fixed;
    top: 0;
    right: -600px;
    /* Hidden by default */
    width: 550px;
    max-width: 90%;
    height: 100%;
    background: white;
    z-index: 999999;
    box-shadow: -10px 0 30px rgba(0, 0, 0, 0.2);
    transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
}

.pb-drawer.open {
    right: 0;
}

.drawer-header {
    padding: 24px;
    border-bottom: 1px solid var(--pb-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #fff;
}

.drawer-header h3 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 700;
}

.close-drawer {
    font-size: 24px;
    cursor: pointer;
    color: var(--pb-text-muted);
    transition: color 0.2s;
}

.close-drawer:hover {
    color: var(--pb-text-main);
}

.drawer-body {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    background: #f8fafc;
}

.drawer-section {
    background: white;
    padding: 24px;
    border-radius: 12px;
    border: 1px solid var(--pb-border);
    margin-bottom: 24px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.drawer-section h4 {
    margin: 0 0 8px 0;
    font-size: 0.95rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--pb-text-muted);
}

.drawer-help {
    margin: 0 0 20px 0;
    font-size: 0.9rem;
    color: var(--pb-text-main);
}

/* Drawer Inputs */
.drawer-input-group {
    margin-bottom: 16px;
}

.drawer-input-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    font-size: 0.9rem;
}

.drawer-input-group input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--pb-border);
    border-radius: 8px;
    font-size: 0.95rem;
    transition: all 0.2s;
}

.drawer-input-group input:focus {
    border-color: var(--pb-primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
    outline: none;
}

/* Prompt Output Box */
.prompt-output-wrapper {
    border: 1px solid var(--pb-border);
    border-radius: 8px;
    overflow: hidden;
}

textarea#final-prompt-output {
    width: 100%;
    height: 200px;
    padding: 16px;
    border: none;
    resize: none;
    font-family: 'Menlo', monospace;
    font-size: 0.9rem;
    line-height: 1.6;
    color: var(--pb-text-main);
    background: #fff;
    display: block;
}

textarea#final-prompt-output:focus {
    outline: none;
}

.prompt-actions {
    padding: 12px 16px;
    background: #f1f5f9;
    border-top: 1px solid var(--pb-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#copy-prompt-btn {
    background: var(--pb-primary);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.9rem;
    transition: all 0.2s;
}

#copy-prompt-btn:hover {
    background: var(--pb-primary-dark);
}

.ai-badges {
    display: flex;
    gap: 8px;
}

.ai-badge {
    background: white;
    border: 1px solid var(--pb-border);
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--pb-text-muted);
}

/* Responsive Drawer */
@media (max-width: 600px) {
    .pb-drawer {
        width: 100%;
        max-width: 100%;
    }
}

/* Profile Grid */
.profile-grid-layout {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 24px;
}

/* Completion Widget */
.completion-card {
    padding: 24px;
    margin-bottom: 24px;
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: white;
    border: none;
}

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

.completion-header h3 {
    color: white;
    margin: 0;
    font-size: 1.1rem;
}

.completion-percent {
    font-size: 1.5rem;
    font-weight: 800;
}

.completion-bar-bg {
    background: rgba(255, 255, 255, 0.2);
    height: 8px;
    border-radius: 4px;
    margin-bottom: 12px;
    overflow: hidden;
}

.completion-bar-fill {
    background: #ffffff;
    height: 100%;
    border-radius: 4px;
    transition: width 1s ease-out;
}

.completion-text {
    margin: 0;
    font-size: 0.9rem;
    opacity: 0.9;
}

/* Account Card */
.account-card .pb-card-body {
    padding: 24px;
}

.info-row {
    margin-bottom: 16px;
    border-bottom: 1px solid #f1f5f9;
    padding-bottom: 12px;
}

.info-row:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.info-row label {
    display: block;
    font-size: 0.8rem;
    color: var(--pb-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 4px;
}

.info-row span {
    font-weight: 600;
    color: var(--pb-text-main);
    font-size: 1rem;
}

.plan-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 700;
}

.plan-badge.free {
    background: #dcfce7;
    color: #15803d;
}

/* Footer */
.pb-footer {
    padding: 24px 32px;
    border-top: 1px solid var(--pb-border);
    text-align: center;
    color: var(--pb-text-muted);
    font-size: 0.85rem;
    background: white;
    margin-top: auto;
    /* Push to bottom */
}

/* Responsive Profile */
@media (max-width: 768px) {
    .profile-grid-layout {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 1024px) {
    .pb-sidebar {
        width: 80px;
    }

    .pb-brand h2,
    .pb-user-info,
    .nav-text {
        display: none;
    }

    .pb-nav-item {
        justify-content: center;
        padding: 16px;
    }

    .pb-nav-item .dashicons {
        margin: 0;
        font-size: 24px;
    }

    .pb-user-card {
        justify-content: center;
        padding: 20px 0;
    }
}

@media (max-width: 768px) {
    .pb-app-container {
        flex-direction: column;
        position: relative;
        /* Allow scroll on mobile */
        height: auto;
        overflow: auto;
    }

    .pb-sidebar {
        width: 100%;
        height: auto;
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        padding: 0 16px;
    }

    .pb-nav {
        display: none;
        /* Add hamburger later */
    }

    .pb-main {
        height: auto;
        min-height: calc(100vh - 120px);
    }

    .modal-body {
        flex-direction: column;
        overflow-y: auto;
    }

    .modal-left,
    .modal-right {
        width: 100%;
    }
}

/* --- Onboarding Modal --- */
.prompts-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(4px);
    z-index: 9999999;
    /* Top of everything */
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content.small {
    width: 100%;
    max-width: 450px;
    background: white;
    padding: 32px;
    border-radius: 16px;
    box-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
    animation: modalPop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-header {
    text-align: center;
    margin-bottom: 24px;
}

.modal-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--pb-text-main);
    margin: 0 0 8px 0;
}

.modal-header p {
    color: var(--pb-text-muted);
    font-size: 0.95rem;
    margin: 0;
}

.modal-body label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--pb-text-main);
    margin-top: 16px;
}

.modal-body select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--pb-border);
    border-radius: 8px;
    font-size: 1rem;
    background: white;
}

.modal-body .primary-btn {
    margin-top: 24px;
}

@keyframes modalPop {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(10px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}