/* Email Services View Styles - JustOpened 1:1 Parity with BetterBase */

:root {
    --bg-primary: #0a0b1e;
    --bg-secondary: #0f172a;
    --border-color: rgba(255, 255, 255, 0.08);
    --text-primary: #ffffff;
    --text-secondary: #94a3b8;
    --accent-primary: #3b82f6;
    --hover-bg: rgba(255, 255, 255, 0.05);
}

#email-services-view,
.email-full-view {
    overflow: hidden !important;
    padding: 0 !important;
    max-width: none !important;
    width: 100% !important;
    margin: 0 !important;
    flex-direction: column !important;
    height: 100% !important;
    overflow-y: hidden !important;
    display: flex;
    flex: 1;
    border-top-left-radius: 30px;
}

.email-container {
    display: flex;
    height: 100%;
    width: 100%;
    overflow: hidden;
    position: relative;
    background: #0a0b1e;
    border-top-left-radius: 30px;
}

.email-sidebar {
    position: relative !important;
    width: 260px !important;
    background: #0d121f !important;
    border-right: 1px solid rgba(255, 255, 255, 0.08) !important;
    display: flex !important;
    flex-direction: column !important;
    flex-shrink: 0 !important;
    transition: width 0.22s cubic-bezier(0.4, 0, 0.2, 1) !important;
    overflow: visible !important;
    z-index: 20;
}

/* Collapsed state for sub-sidebar */
.email-sidebar.sub-sidebar-collapsed {
    width: 0 !important;
    min-width: 0 !important;
    max-width: 0 !important;
    border-right: none !important;
    overflow: hidden !important;
}

.email-sidebar.sub-sidebar-collapsed > * {
    opacity: 0 !important;
    pointer-events: none !important;
    transition: opacity 0.12s !important;
}

.email-sidebar-header {
    padding: 24px 20px 14px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.email-sidebar-title {
    font-size: 16px;
    font-weight: 700;
    color: #ffffff;
    margin: 0;
    letter-spacing: -0.2px;
}

.email-sidebar-categories {
    flex: 1;
    overflow-y: auto;
    padding: 16px 0;
}

.email-sidebar-category {
    margin-bottom: 24px;
}

.email-category-label {
    padding: 0 20px 8px 20px;
    font-size: 11px;
    font-weight: 700;
    color: #64748b;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.email-nav-item {
    padding: 10px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 13px;
    color: #94a3b8;
    cursor: pointer;
    transition: all 0.2s;
    user-select: none;
    border-left: 3px solid transparent;
}

.email-nav-item svg {
    opacity: 0.7;
    flex-shrink: 0;
    transition: all 0.2s;
}

.email-nav-item:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.04);
}

.email-nav-item:hover svg {
    opacity: 1;
    color: #38bdf8;
}

.email-nav-item.active {
    color: #ffffff;
    background: rgba(59, 130, 246, 0.12);
    font-weight: 600;
    border-left-color: #3b82f6;
}

.email-nav-item.active svg {
    color: #3b82f6;
    opacity: 1;
}

/* Toggle arrow button — sits on the right edge of sidebar at top */
.sub-sidebar-toggle {
    position: absolute !important;
    top: 20px !important;
    left: 260px !important;
    transform: translateX(-50%) !important;
    width: 22px !important;
    height: 32px !important;
    background: #0f172a !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    border-radius: 0 6px 6px 0 !important;
    color: #94a3b8 !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    z-index: 35 !important;
    transition: background 0.15s, color 0.15s, left 0.22s cubic-bezier(0.4, 0, 0.2, 1), transform 0.22s cubic-bezier(0.4, 0, 0.2, 1) !important;
    padding: 0 !important;
    flex-shrink: 0 !important;
}

.sub-sidebar-toggle:hover {
    background: #1e293b !important;
    color: #ffffff !important;
}

.sub-sidebar-toggle.collapsed {
    left: 0 !important;
    transform: none !important;
    border-left: 1px solid rgba(255, 255, 255, 0.1) !important;
    border-radius: 0 6px 6px 0 !important;
}

.email-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #0a0b1e;
    min-width: 0;
    height: 100%;
    overflow: hidden;
    position: relative;
}

.email-content {
    flex: 1;
    overflow-y: auto;
    height: 100%;
    position: relative;
}

/* Template Gallery View Wrapper */
.bb-gallery-view-wrapper {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    background: #090d16;
    color: #ffffff;
    overflow: hidden;
}

.bb-gallery-header-bar {
    padding: 12px 20px;
    background: rgba(15, 23, 42, 0.8);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-shrink: 0;
}

.bb-gallery-breadcrumb {
    font-size: 13px;
    color: #94a3b8;
    display: flex;
    align-items: center;
    gap: 8px;
}

.bb-gallery-breadcrumb span.active {
    color: #ffffff;
    font-weight: 600;
}

.templates-app-container {
    display: flex;
    flex-direction: row;
    flex: 1;
    width: 100%;
    overflow: hidden;
}

.templates-sidebar {
    width: 220px;
    flex-shrink: 0;
    border-right: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    flex-direction: column;
    background: rgba(15, 23, 42, 0.5);
}

.templates-sidebar-header {
    padding: 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.templates-sidebar-header h2 {
    font-size: 15px;
    font-weight: 700;
    color: #ffffff;
    margin: 0 0 12px 0;
}

.templates-grid-container {
    flex: 1;
    overflow-y: auto;
    padding: 30px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    row-gap: 30px;
    column-gap: 24px;
    align-content: start;
}

.template-card {
    cursor: pointer;
    transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
    overflow: hidden;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    flex-direction: column;
    position: relative;
    box-sizing: border-box;
    min-height: 250px;
}

.template-card:hover {
    transform: translateY(-3px);
    border-color: #3b82f6;
    box-shadow: 0 8px 20px rgba(59, 130, 246, 0.2);
}

.template-card.selected,
.template-card.active {
    border-color: #3b82f6;
    box-shadow: inset 0 0 0 2px rgba(59, 130, 246, 0.5);
}

.template-thumb {
    width: 100%;
    height: 180px;
    object-fit: cover;
    flex-shrink: 0;
    display: block;
    background: #1e293b;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.template-badge-ribbon {
    position: absolute;
    top: 8px;
    left: 8px;
    background: rgba(239, 68, 68, 0.9);
    color: #ffffff;
    font-size: 10px;
    font-weight: 800;
    padding: 2px 7px;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
    z-index: 2;
}

.template-info {
    padding: 12px;
    text-align: center;
    flex-grow: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.template-name {
    font-size: 13px;
    font-weight: 600;
    color: #ffffff;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Right Preview Side Pane */
.templates-preview-pane {
    width: 320px;
    flex-shrink: 0;
    border-left: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(15, 23, 42, 0.6);
    display: flex;
    flex-direction: column;
    padding: 20px;
    overflow-y: auto;
}

.preview-header {
    margin-bottom: 16px;
}

.preview-title {
    font-size: 17px;
    font-weight: 800;
    margin-bottom: 4px;
    color: #ffffff;
}

.preview-subtitle {
    font-size: 12px;
    color: #94a3b8;
}

.preview-image-container {
    width: 100%;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.1);
    margin-bottom: 16px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    background: #0b0f19;
}

.preview-image {
    width: 100%;
    display: block;
}

.action-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.btn-blue-primary {
    background: #3b82f6;
    color: #ffffff;
    border: none;
    border-radius: 8px;
    padding: 10px 16px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: background 0.2s;
}

.btn-blue-primary:hover {
    background: #2563eb;
}

.btn-dark-outline {
    background: rgba(255, 255, 255, 0.04);
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    padding: 9px 14px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all 0.2s;
}

.btn-dark-outline:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.3);
}

/* Modals */
.bb-editor-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.bb-editor-card {
    background: #0f172a;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 14px;
    width: 100%;
    max-width: 960px;
    height: 85vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.7);
}

/* Responsive adjustments */
@media (max-width: 900px) {
    .email-container {
        flex-direction: column;
    }
    .email-sidebar {
        width: 100% !important;
        height: auto;
        border-right: none !important;
        border-bottom: 1px solid rgba(255, 255, 255, 0.08) !important;
    }
    .sub-sidebar-toggle {
        display: none !important;
    }
    .templates-preview-pane {
        display: none;
    }
}

/* Category Templates & Sub-screens Styling (BetterBase 1:1 Parity) */
.bb-breadcrumb-link {
    cursor: pointer;
    transition: color 0.15s ease;
}
.bb-breadcrumb-link:hover {
    color: #ffffff !important;
}

.bb-category-subtab-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    transition: all 0.15s ease;
}
.bb-category-subtab-btn:hover {
    color: #ffffff !important;
}

.bb-category-template-card {
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
.bb-category-template-card:hover {
    transform: translateY(-3px);
}

.bb-var-pill {
    transition: all 0.15s ease;
    user-select: none;
}
.bb-var-pill:hover {
    border-color: #10b981 !important;
    color: #10b981 !important;
    background: rgba(16, 185, 129, 0.1) !important;
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
    }
    to {
        transform: translateX(0);
    }
}
