/* CSS Variables / Theme Tokens for Jobready */
:root {
    --primary-color: #4361ee;
    --primary-hover: #3a0ca3;
    --bg-main: #f8fafc;
    --bg-card: #ffffff;
    --sidebar-bg: #0f172a;
    --sidebar-text: #94a3b8;
    --sidebar-hover-bg: #1e293b;
    --sidebar-active-text: #ffffff;
    --text-main: #334155;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --transition-speed: 0.3s;
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    line-height: 1.5;
}

/* App Layout Structure */
.app-container {
    display: flex;
    min-height: 100vh;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background-color: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    transition: width var(--transition-speed) ease;
    z-index: 100;
}

.sidebar.collapsed {
    width: 80px;
}

.sidebar.collapsed .sidebar-header h2 span,
.sidebar.collapsed .sidebar-nav li span {
    display: none !important;
    /* fallback if JS needed, but CSS popout below is better */
}

/* Base styles for labels in compact mode to allow popout */
.sidebar.collapsed .sidebar-nav li {
    position: relative;
    overflow: visible;
    /* ensure popout is visible */
}

.sidebar.collapsed .sidebar-nav li span {
    display: none !important;
    position: absolute;
    left: 70px;
    background: var(--sidebar-bg);
    color: white;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 0.85rem;
    white-space: nowrap;
    box-shadow: 5px 5px 15px rgba(0, 0, 0, 0.3);
    z-index: 1000;
    pointer-events: none;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar.collapsed .sidebar-nav li:hover span {
    display: block !important;
    opacity: 1;
    visibility: visible;
    transform: translateX(0);
}

.sidebar.collapsed .full-logo {
    display: none !important;
}

.sidebar .compact-logo {
    display: none;
}

.sidebar.collapsed .compact-logo {
    display: block;
    height: 42px;
    width: auto;
    filter: drop-shadow(0 0 8px rgba(67, 97, 238, 0.3));
}

.sidebar-header {
    height: 70px;
    padding: 0 24px;
    display: flex;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.sidebar.collapsed .sidebar-header {
    padding: 0;
    justify-content: center;
}

.sidebar-header .logo-container {
    display: flex;
    align-items: center;
    transition: all 0.3s;
}

.sidebar-header .logo-container img {
    height: 48px;
    width: auto;
}

.sidebar-nav {
    padding: 20px 0;
    flex: 1;
    overflow-y: auto;
}

.sidebar-nav ul {
    list-style: none;
}

.sidebar-nav li {
    padding: 12px 24px;
    margin: 4px 12px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 16px;
    font-weight: 500;
    font-size: 0.95rem;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.sidebar-nav li:hover {
    background-color: var(--sidebar-hover-bg);
    color: var(--sidebar-active-text);
}

.sidebar-nav li.active {
    background-color: rgba(67, 97, 238, 0.1);
    color: var(--primary-color);
    border-left: 5px solid var(--primary-color);
    box-shadow: inset 0 0 0 1px rgba(67, 97, 238, 0.05);
}

.sidebar.collapsed .sidebar-nav li.active {
    background-color: var(--primary-color);
    color: white;
    border-left: none;
    box-shadow: 0 4px 12px rgba(67, 97, 238, 0.3);
}

.sidebar-nav li .menu-icon {
    font-size: 1.1rem;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
}

.sidebar.collapsed .sidebar-nav li {
    padding: 12px 0;
    justify-content: center;
    margin: 4px 12px;
    width: auto;
    border-radius: 10px;
}

.sidebar.collapsed .sidebar-nav li .menu-icon {
    width: auto;
    margin: 0;
}

.sidebar.collapsed .sidebar-nav li.active .menu-icon {
    color: white;
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    /* Prevents flex flex-grow overflow */
}

/* Header */
.top-header {
    height: 70px;
    background-color: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 30px;
}

.header-left,
.header-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

.btn-icon {
    background: transparent;
    border: none;
    font-size: 1.2rem;
    color: var(--text-muted);
    cursor: pointer;
    transition: color 0.2s;
    padding: 8px;
}

.btn-icon:hover {
    color: var(--primary-color);
}

.header-search {
    display: flex;
    align-items: center;
    background-color: var(--bg-main);
    padding: 8px 16px;
    border-radius: 20px;
    width: 320px;
    transition: width 0.3s;
}

.header-search:focus-within {
    width: 400px;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(67, 97, 238, 0.1);
}

.header-search i {
    color: var(--text-muted);
}

.header-search input {
    border: none;
    background: transparent;
    margin-left: 10px;
    width: 100%;
    outline: none;
    font-family: inherit;
    font-size: 0.95rem;
    color: var(--text-main);
}

/* Profile Section Enhancements */
.profile-wrapper {
    position: relative;
    user-select: none;
}

.user-profile {
    position: relative;
    cursor: pointer;
    padding: 2px;
    border-radius: 50%;
    transition: background 0.2s;
}

.user-profile:hover {
    background: rgba(0, 0, 0, 0.05);
}

.user-profile .avatar {
    width: 36px;
    height: 36px;
    background-color: var(--primary-color);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    overflow: hidden;
    border: 2px solid transparent;
    transition: border-color 0.2s;
}

.user-profile:hover .avatar {
    border-color: rgba(67, 97, 238, 0.2);
}

.user-profile .avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Hover Tooltip */
.profile-tooltip {
    position: absolute;
    top: 50px;
    right: 0;
    background: #444746;
    color: #e3e3e3;
    padding: 12px 16px;
    border-radius: 8px;
    width: max-content;
    max-width: 280px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-5px);
    transition: all 0.2s ease;
    z-index: 1001;
    text-align: left;
}

.user-profile:hover .profile-tooltip {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.tooltip-title {
    font-size: 0.75rem;
    color: #c4c7c5;
    margin-bottom: 4px;
}

.tooltip-name {
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 2px;
}

.tooltip-email {
    font-size: 0.8rem;
    opacity: 0.8;
}

/* Profile Popup */
.profile-popup {
    position: absolute;
    top: 50px;
    right: 0;
    width: 380px;
    background: #2d2f31;
    color: #e3e3e3;
    border-radius: 28px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    z-index: 2000;
    display: none;
    flex-direction: column;
    overflow: hidden;
    padding: 8px;
}

.profile-popup.active {
    display: flex;
}

.popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
}

.popup-email {
    font-size: 0.85rem;
    color: #c4c7c5;
}

.btn-close-popup {
    background: transparent;
    border: none;
    color: #c4c7c5;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
}

.btn-close-popup:hover {
    background: rgba(255, 255, 255, 0.05);
}

.popup-body {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px 0;
    text-align: center;
}

.popup-avatar-container {
    position: relative;
    margin-bottom: 16px;
}

.large-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    overflow: hidden;
    background: var(--primary-color);
}

.large-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.edit-avatar-btn {
    position: absolute;
    bottom: -5px;
    right: -5px;
    background: #3c4043;
    border: 1px solid #5f6368;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.popup-greeting {
    font-size: 1.4rem;
    margin-bottom: 24px;
    font-weight: 400;
}

.btn-manage-account {
    background: transparent;
    border: 1px solid #8e918f;
    color: #c2e7ff;
    padding: 10px 24px;
    border-radius: 20px;
    font-weight: 500;
    cursor: pointer;
}

.btn-manage-account:hover {
    background: rgba(194, 231, 255, 0.05);
}

.popup-roles-section {
    background: #1e1f20;
    margin: 8px;
    border-radius: 20px;
    padding: 16px;
}

.section-title {
    font-size: 0.75rem;
    color: #c4c7c5;
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.roles-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.role-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: 12px;
    cursor: pointer;
    transition: background 0.2s;
}

.role-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.role-item.active {
    background: rgba(67, 97, 238, 0.15);
    border: 1px solid rgba(67, 97, 238, 0.3);
}

.role-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #3c4043;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
}

.role-info {
    text-align: left;
}

.role-name {
    display: block;
    font-weight: 500;
    font-size: 0.9rem;
}

.role-org {
    display: block;
    font-size: 0.75rem;
    color: #94a3b8;
}

.popup-footer {
    display: flex;
    justify-content: center;
    padding: 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.btn-logout {
    background: #3c4043;
    color: #f2f2f2;
    border: none;
    padding: 12px 32px;
    border-radius: 12px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    justify-content: center;
}

.btn-logout:hover {
    background: #4a4e52;
}

/* Launcher Wrapper & Trigger */
.launcher-wrapper {
    position: relative;
}

.launcher-trigger {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.2s;
}

.launcher-trigger:hover {
    background: rgba(0, 0, 0, 0.05);
}

/* Launcher Popup */
.launcher-popup {
    position: absolute;
    top: 50px;
    right: -10px;
    width: 380px;
    background: #f8fafc;
    /* Match bg-main */
    color: var(--text-main);
    border-radius: 28px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    z-index: 2000;
    display: none;
    flex-direction: column;
    padding: 24px;
    border: 1px solid var(--border-color);
}

.launcher-popup.active {
    display: flex;
}

.launcher-header {
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
}

.launcher-header h3 {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.launcher-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    max-height: 480px;
    overflow-y: auto;
}

.launcher-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 12px 8px;
    border-radius: 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
}

.launcher-item:hover {
    background: rgba(255, 255, 255, 0.08);
}

.launcher-item-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: var(--primary-color);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
    transition: all 0.2s;
}

.launcher-item:hover .launcher-item-icon {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.1);
}

.launcher-item span {
    font-size: 0.85rem;
    color: var(--text-main);
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    width: 100%;
}

/* Content Body */
.content-body {
    padding: 30px;
    flex: 1;
    overflow-y: auto;
}

/* Reusable Components */
.card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02);
}

.btn {
    padding: 10px 20px;
    border-radius: 8px;
    font-family: inherit;
    font-weight: 500;
    font-size: 0.9rem;
    cursor: pointer;
    border: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
}

/* Dashboard Specifics */
.dashboard-metrics {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 24px;
    margin-top: 24px;
}

.metric-card {
    display: flex;
    align-items: center;
    gap: 20px;
}

.metric-icon {
    width: 60px;
    height: 60px;
    border-radius: 12px;
    background-color: rgba(67, 97, 238, 0.1);
    color: var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.metric-info h3 {
    font-size: 0.85rem;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.metric-info .value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-main);
}
/* Modal System */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.modal-overlay.active {
    display: flex;
    opacity: 1;
}

.modal-content {
    background: white;
    width: 800px;
    max-width: 95%;
    max-height: 92vh;           /* cap total modal height */
    border-radius: 20px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    transform: translateY(20px);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    overflow: hidden;
    display: flex;              /* flex column so body can scroll independently */
    flex-direction: column;
}

/* Grid System for Forms */
.row {
    display: flex;
    flex-wrap: wrap;
    margin-right: -10px;
    margin-left: -10px;
}

.col-1, .col-2, .col-3, .col-4, .col-5, .col-6, .col-7, .col-8, .col-9, .col-10, .col-11, .col-12 {
    position: relative;
    width: 100%;
    padding-right: 10px;
    padding-left: 10px;
    box-sizing: border-box;
}

.col-1 { flex: 0 0 8.333333%; max-width: 8.333333%; }
.col-2 { flex: 0 0 16.666667%; max-width: 16.666667%; }
.col-3 { flex: 0 0 25%; max-width: 25%; }
.col-4 { flex: 0 0 33.333333%; max-width: 33.333333%; }
.col-5 { flex: 0 0 41.666667%; max-width: 41.666667%; }
.col-6 { flex: 0 0 50%; max-width: 50%; }
.col-7 { flex: 0 0 58.333333%; max-width: 58.333333%; }
.col-8 { flex: 0 0 66.666667%; max-width: 66.666667%; }
.col-9 { flex: 0 0 75%; max-width: 75%; }
.col-10 { flex: 0 0 83.333333%; max-width: 83.333333%; }
.col-11 { flex: 0 0 91.666667%; max-width: 91.666667%; }
.col-12 { flex: 0 0 100%; max-width: 100%; }

.modal-overlay.active .modal-content {
    transform: translateY(0);
}

/* Wide modal variant — used for forms with embedded tables (e.g. Designations) */
.modal-content.modal-wide {
    width: 1000px;
    max-width: 96%;
}

.modal-header {
    padding: 24px 32px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;             /* never shrink — always pinned at top */
}

.modal-header h3 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--sidebar-bg);
}

.modal-body {
    padding: 32px;
    flex: 1;                    /* take all remaining height */
    overflow-y: auto;           /* scroll only the body */
}

.modal-footer {
    padding: 20px 32px;
    background: var(--bg-main);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    border-top: 1px solid var(--border-color);
    flex-shrink: 0;             /* never shrink — always pinned at bottom */
}

/* Form Styling */
.form-group {
    margin-bottom: 20px;
}

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

.form-control {
    width: 100%;
    padding: 12px 16px;
    border: 1.5px solid var(--border-color);
    border-radius: 10px;
    font-size: 1rem;
    transition: all 0.2s;
    outline: none;
    color: var(--text-main);
    background: white;
}

.form-control:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(67, 97, 238, 0.1);
}

.form-control::placeholder {
    color: #cbd5e1;
}

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2364748b' stroke-width='2'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
    background-size: 16px;
    padding-right: 48px;
}

input[type="color"].form-control {
    height: 48px;
    padding: 6px;
    background: #ffffff;
    cursor: pointer;
}

input[type="color"].form-control::-webkit-color-swatch-wrapper {
    padding: 0;
}

input[type="color"].form-control::-webkit-color-swatch {
    border: 1px solid var(--border-color);
    border-radius: 6px;
}

input[type="color"].form-control::-moz-color-swatch {
    border: 1px solid var(--border-color);
    border-radius: 6px;
}

input[type="color"].color-picker-swatch {
    cursor: pointer;
}

input[type="color"].color-picker-swatch::-webkit-color-swatch-wrapper {
    padding: 0;
}

input[type="color"].color-picker-swatch::-webkit-color-swatch {
    border: none;
}

input[type="color"].color-picker-swatch::-moz-color-swatch {
    border: none;
}

/* Select2 Premium Customization */
.select2-container--default .select2-selection--single {
    border: 1.5px solid var(--border-color);
    border-radius: 10px;
    height: 48px;
    display: flex;
    align-items: center;
    transition: all 0.2s;
    outline: none;
}

.select2-container--default .select2-selection--single .select2-selection__rendered {
    color: var(--text-main);
    padding-left: 16px;
    font-size: 1rem;
}

.select2-container--default .select2-selection--single .select2-selection__arrow {
    height: 46px;
    right: 12px;
}

.select2-container--default.select2-container--focus .select2-selection--single {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(67, 97, 238, 0.1);
}

.select2-dropdown {
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    overflow: hidden;
    z-index: 10001;
    margin-top: 5px;
}

.select2-results__option {
    padding: 12px 16px;
    font-size: 0.95rem;
    transition: background 0.2s;
}

.select2-container--default .select2-results__option--highlighted[aria-selected] {
    background-color: var(--primary-color);
}

.select2-container--default .select2-search--dropdown .select2-search__field {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 8px 12px;
    outline: none;
}

/* Template Designer Styles */
.sortable-list {
    min-height: 50px;
}

.designer-item {
    background: white;
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: grab;
    transition: all 0.2s;
    user-select: none;
}

.designer-item:hover {
    border-color: var(--primary-color);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.designer-item .handle {
    color: #cbd5e1;
    cursor: grab;
}

.designer-item .item-type {
    font-size: 0.7rem;
    padding: 2px 6px;
    background: #f1f5f9;
    border-radius: 4px;
    color: #64748b;
    text-transform: uppercase;
}

.canvas-item {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    margin-bottom: 12px;
    padding: 15px;
    position: relative;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.canvas-item .item-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px dashed #f1f5f9;
}

.canvas-item .remove-item {
    color: #94a3b8;
    cursor: pointer;
    transition: color 0.2s;
}

.canvas-item .remove-item:hover {
    color: var(--danger);
}

.ghost-item {
    opacity: 0.4;
    background: var(--primary-color) !important;
}

.chosen-item {
    border: 2px solid var(--primary-color);
}

/* Tab Designer Specifics */
.designer-tab-item {
    background: #4f46e5;
    color: white;
    padding: 8px 16px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 4px 6px -1px rgba(79, 70, 229, 0.2);
    border: 1px solid #4338ca;
    animation: slideIn 0.3s ease;
}

.designer-tab-item input {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    font-size: 0.8rem;
    padding: 4px 8px;
    border-radius: 4px;
    width: 100px;
    outline: none;
    transition: all 0.2s;
}

.designer-tab-item input:focus {
    background: white;
    color: var(--sidebar-bg);
    width: 140px;
}

.designer-tab-item .remove-tab {
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.designer-tab-item .remove-tab:hover {
    opacity: 1;
}

@keyframes slideIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Nested Designer Layout */
.canvas-item.active-tab-context {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px var(--primary-color)20;
}

.designer-tab-item.active {
    background: white;
    color: var(--primary-color);
    border-color: var(--primary-color);
    box-shadow: 0 8px 16px rgba(0,0,0,0.1);
}

.designer-tab-item.active input {
    background: #f1f5f9;
    color: var(--sidebar-bg);
}

.column-container {
    min-height: 80px;
    background: rgba(255,255,255,0.5);
    border: 1px dashed #cbd5e1;
    border-radius: 8px;
    padding: 10px;
    margin-top: 10px;
}

.canvas-item[data-type-id="12"] { /* Column */
    border-style: solid;
    background: #f0fdf4;
}

.canvas-item[data-type-id="12"] .column-dropzone {
    min-height: 60px;
    border: 1px dashed #10b981;
    border-radius: 6px;
    background: rgba(16, 185, 129, 0.05);
    padding: 10px;
}

/* Premium Modern UI Framework Enhancements */

/* Smooth modal entry transition */
.modal-overlay {
    transition: opacity 0.25s cubic-bezier(0.4, 0, 0.2, 1), backdrop-filter 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-content {
    transform: scale(0.95) translateY(10px);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s ease;
}

.modal-overlay.active .modal-content {
    transform: scale(1) translateY(0);
    box-shadow: 0 25px 50px -12px rgba(15, 23, 42, 0.25);
}

/* Slicker form input states */
.form-control {
    border-color: #cbd5e1;
    font-weight: 500;
}

.form-control:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(67, 97, 238, 0.12);
    background: #ffffff;
}

/* Symmetrical and visually balanced padding/spacing for form elements */
.form-group {
    margin-bottom: 24px;
}

/* Premium Select2 Styling Overrides */
.select2-container--default .select2-selection--single {
    border-color: #cbd5e1;
    background-color: #ffffff;
    font-weight: 500;
}

.select2-container--default.select2-container--open .select2-selection--single {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(67, 97, 238, 0.12);
}

.select2-dropdown {
    border: 1px solid var(--border-color);
    box-shadow: 0 12px 30px rgba(15, 23, 42, 0.1);
    border-radius: 12px;
}

.select2-container--default .select2-results__option--highlighted[aria-selected] {
    background-color: var(--primary-color);
    color: #ffffff;
    font-weight: 500;
}

.select2-results__option {
    font-weight: 500;
    color: var(--text-main);
}

/* General visual details */
.modal-header h3 {
    font-size: 1.35rem;
    font-weight: 700;
    color: #1e293b;
    letter-spacing: -0.02em;
}

.modal-footer {
    border-top: 1px solid rgba(226, 232, 240, 0.8);
    background: #f8fafc;
}

.btn-primary {
    box-shadow: 0 4px 12px rgba(67, 97, 238, 0.25);
}

.btn-primary:hover {
    box-shadow: 0 6px 20px rgba(67, 97, 238, 0.35);
}

.btn-danger {
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.2);
}

.btn-danger:hover {
    box-shadow: 0 6px 20px rgba(239, 68, 68, 0.3);
}

/* Smooth micro-animations for grid actions */
.btn-edit-row:hover {
    background: var(--primary-color) !important;
    color: white !important;
    border-color: var(--primary-color) !important;
    transform: translateY(-1px);
}

.btn-delete-row:hover {
    background: var(--danger) !important;
    color: white !important;
    border-color: var(--danger) !important;
    transform: translateY(-1px);
}

.btn-list-children:hover {
    background: var(--success) !important;
    color: white !important;
    border-color: var(--success) !important;
    transform: translateY(-1px);
}

/* -- Template Designer Tab Buttons ---------------- */
.d-tab-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    font-size: 0.83rem;
    font-weight: 600;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: white;
    color: #475569;
    cursor: pointer;
    transition: background 0.18s, color 0.18s, border-color 0.18s;
    white-space: nowrap;
}
.d-tab-btn:hover { background: #f1f5f9; }
.d-tab-active {
    background: #1e293b !important;
    color: white !important;
    border-color: #1e293b !important;
}
.d-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    font-size: 0.83rem;
    font-weight: 500;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: white;
    color: #475569;
    cursor: pointer;
    transition: background 0.15s;
    white-space: nowrap;
}
.d-action-btn:hover { background: #f8fafc; }

/* Employee custom modal styles */
.employee-tab-btn {
    padding: 10px 22px;
    font-weight: 600;
    font-size: 0.85rem;
    border-radius: 8px;
    border: 1.5px solid var(--border-color);
    background: #f8fafc;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s ease;
}
.employee-tab-btn:hover {
    background: #e2e8f0;
    color: var(--text-main);
}
.employee-tab-btn.active {
    background: var(--primary-color) !important;
    color: #ffffff !important;
    border-color: var(--primary-color) !important;
}

.employee-header-btn:hover, .employee-close-btn:hover {
    background: #e2e8f0 !important;
    border-color: #cbd5e1 !important;
}

.employee-field-label {
    font-weight: 700;
    color: #dc2626;
    text-transform: uppercase;
    font-size: 0.8rem;
    display: block;
    margin-bottom: 8px;
    letter-spacing: 0.5px;
}

.employee-field-input {
    border-radius: 8px !important;
    font-size: 0.95rem !important;
    padding: 10px 14px !important;
    height: auto !important;
}

/* Profile Photo Uploader */
.employee-profile-upload-wrap {
    width: 140px;
    height: 140px;
    border: 2px dashed #cbd5e1;
    border-radius: 12px;
    background: #f8fafc;
    cursor: pointer;
    position: relative;
    transition: all 0.2s ease;
    overflow: hidden;
}
.employee-profile-upload-wrap:hover {
    border-color: var(--primary-color);
    background: #f1f5f9;
}
.employee-profile-upload-wrap .upload-preview-container {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}
.employee-profile-upload-wrap .employee-profile-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.employee-profile-upload-wrap .upload-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    width: 100%;
    height: 100%;
}
.employee-profile-upload-wrap .placeholder-gallery-icon {
    font-size: 4rem;
    color: #94a3b8;
    margin-top: 5px;
}
.employee-profile-upload-wrap .plus-icon-container {
    position: absolute;
    top: 30px;
    right: 32px;
    background: #ffffff;
    border: 1.5px solid #94a3b8;
    color: #0f172a;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.65rem;
    font-weight: bold;
}

/* File attachments uploader */
.employee-attachment-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
}
.employee-attachment-group .file-uploader-row {
    display: flex;
    gap: 8px;
    align-items: center;
    width: 100%;
}
.employee-attachment-group .file-choose-btn-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
    border: 1.5px solid var(--border-color);
    border-radius: 8px;
    background: #ffffff;
    overflow: hidden;
    padding: 0;
}
.employee-attachment-group .btn-choose-file {
    padding: 10px 16px;
    background: #f1f5f9;
    border: none;
    border-right: 1.5px solid var(--border-color);
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-main);
    cursor: pointer;
    transition: all 0.2s;
}
.employee-attachment-group .btn-choose-file:hover {
    background: #e2e8f0;
}
.employee-attachment-group .file-chosen-name {
    font-size: 0.82rem;
    color: var(--text-muted);
    padding-left: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 500;
}
.employee-attachment-group .btn-eye-preview {
    width: 44px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #eab308; /* yellow-500 */
    color: #ffffff;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1.1rem;
    transition: all 0.2s;
    text-decoration: none;
}
.employee-attachment-group .btn-eye-preview:hover {
    background: #ca8a04; /* yellow-600 */
    box-shadow: 0 4px 10px rgba(234, 179, 8, 0.25);
}
.employee-attachment-group .btn-eye-preview.disabled {
    background: #e2e8f0;
    color: #cbd5e1;
    cursor: not-allowed;
}
.employee-attachment-group .btn-eye-preview.disabled:hover {
    background: #e2e8f0;
    box-shadow: none;
}

/* Custom HTML Repeatable Rows & Preview Styling */
.custom-head-row, #custom-html-preview {
    font-size: 0.85rem;
}

.custom-head-row .form-control, 
#custom-html-preview .form-control {
    height: 38px !important;
    padding: 8px 12px !important;
    font-size: 0.88rem !important;
    border-radius: 8px !important;
    border: 1.5px solid #cbd5e1 !important;
    box-sizing: border-box !important;
}

/* Align and compact Select2 inside repeatable rows */
.custom-head-row .select2-container--default .select2-selection--single,
#custom-html-preview .select2-container--default .select2-selection--single {
    height: 38px !important;
    border: 1.5px solid #cbd5e1 !important;
    border-radius: 8px !important;
}

.custom-head-row .select2-container--default .select2-selection--single .select2-selection__rendered,
#custom-html-preview .select2-container--default .select2-selection--single .select2-selection__rendered {
    line-height: 35px !important;
    padding-left: 12px !important;
    font-size: 0.88rem !important;
}

.custom-head-row .select2-container--default .select2-selection--single .select2-selection__arrow,
#custom-html-preview .select2-container--default .select2-selection--single .select2-selection__arrow {
    height: 35px !important;
    right: 8px !important;
}

/* Premium Styling for standard Select dropdowns in Repeatable Rows */
.custom-head-row select.form-control,
#custom-html-preview select.form-control {
    padding-right: 28px !important;
    padding-left: 12px !important;
    background-position: right 10px center !important;
    background-size: 12px !important;
}

/* Vertically center the toggle switch */
.custom-head-row .toggle-switch-wrapper,
#custom-html-preview .toggle-switch-wrapper {
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.custom-head-row .toggle-switch,
#custom-html-preview .toggle-switch {
    margin: 0 !important;
}

/* Designation Table Select2 Styling & Alignments */
.designation-table .select2-container--default .select2-selection--single {
    height: 34px !important;
    border: 1px solid #cbd5e1 !important;
    border-radius: 4px !important;
    display: flex;
    align-items: center;
}
.designation-table .select2-container--default .select2-selection--single .select2-selection__arrow {
    height: 32px !important;
    right: 6px !important;
}
.designation-table .select2-container--default .select2-selection--single .select2-selection__rendered {
    line-height: 34px !important;
    padding-left: 8px !important;
    color: #334155 !important;
    font-size: 0.82rem !important;
    text-align: left;
}
.designation-table select, .designation-table input {
    font-size: 0.82rem !important;
}
.designation-table th {
    font-size: 0.78rem !important;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* CKEditor Customizations */
.ck-editor__editable_inline {
    min-height: 200px;
    font-family: inherit;
    color: var(--text-main);
}
.ck-editor {
    width: 100% !important;
}

/* ==========================================
   AI Chatbot Premium Styles
   ========================================== */

.ai-chat-trigger-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
}

.ai-chat-trigger {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(67, 97, 238, 0.05);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    color: var(--text-muted);
    border: 1px solid rgba(67, 97, 238, 0.1);
    padding: 0;
    cursor: pointer;
}

.ai-chat-trigger:hover {
    background: rgba(67, 97, 238, 0.12);
    transform: scale(1.08);
    box-shadow: 0 0 15px rgba(67, 97, 238, 0.3);
}

.ai-chat-trigger i {
    font-size: 1.2rem;
    background: linear-gradient(135deg, #4361ee, #7209b7);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.ai-status-indicator {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 2px solid var(--bg-card);
    transition: background-color 0.3s;
}

.ai-status-indicator.online {
    background-color: var(--success);
    box-shadow: 0 0 6px var(--success);
    animation: status-pulse 2s infinite;
}

.ai-status-indicator.offline {
    background-color: #94a3b8;
    box-shadow: none;
}

@keyframes status-pulse {
    0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.5); }
    70% { box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
    100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

/* Chat Widget Container */
.ai-chat-widget {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 380px;
    height: 540px;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: 20px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15), 
                inset 0 0 0 1px rgba(255, 255, 255, 0.3);
    display: flex;
    flex-direction: column;
    z-index: 1000;
    overflow: hidden;
    transform: translateY(30px) scale(0.95);
    opacity: 0;
    pointer-events: none;
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.ai-chat-widget.active {
    transform: translateY(0) scale(1);
    opacity: 1;
    pointer-events: auto;
}

.ai-chat-widget.minimized {
    height: 66px;
    transform: translateY(0) scale(1);
    opacity: 1;
    pointer-events: auto;
}

/* Header */
.ai-chat-header {
    padding: 16px 20px;
    background: linear-gradient(135deg, rgba(67, 97, 238, 0.95), rgba(114, 9, 183, 0.95));
    color: white;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    cursor: pointer;
    user-select: none;
}

.ai-chat-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.ai-chat-avatar {
    position: relative;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
}

.ai-chat-avatar i {
    font-size: 1rem;
    color: white;
}

.ai-chat-avatar-glow {
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    border-radius: 50%;
    border: 1.5px solid rgba(255, 255, 255, 0.4);
    animation: avatar-spin 6s linear infinite;
}

@keyframes avatar-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.ai-chat-title-group h4 {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 600;
    letter-spacing: 0.3px;
    line-height: 1.2;
}

.ai-chat-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.72rem;
    opacity: 0.85;
    margin-top: 2px;
}

.ai-chat-status .status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: #e2e8f0;
}

.ai-chat-status .status-dot.online {
    background-color: #4ade80;
    box-shadow: 0 0 4px #4ade80;
}

.ai-chat-status .status-dot.offline {
    background-color: #94a3b8;
}

.ai-chat-header-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

.chat-action-btn {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.8);
    cursor: pointer;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    transition: all 0.2s;
}

.chat-action-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    color: white;
}

/* Chat Messages */
.ai-chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: rgba(248, 250, 252, 0.5);
}

.ai-chat-messages::-webkit-scrollbar {
    width: 6px;
}

.ai-chat-messages::-webkit-scrollbar-thumb {
    background-color: rgba(0, 0, 0, 0.08);
    border-radius: 4px;
}

.ai-chat-widget.minimized .ai-chat-messages,
.ai-chat-widget.minimized .ai-chat-suggestions,
.ai-chat-widget.minimized .ai-chat-input-area {
    display: none !important;
}

/* Message Bubbles */
.chat-message {
    display: flex;
    flex-direction: column;
    max-width: 85%;
    animation: message-appear 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes message-appear {
    0% { transform: translateY(10px) scale(0.96); opacity: 0; }
    100% { transform: translateY(0) scale(1); opacity: 1; }
}

.chat-message.user {
    align-self: flex-end;
    align-items: flex-end;
}

.chat-message.assistant {
    align-self: flex-start;
    align-items: flex-start;
}

.message-bubble {
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 0.88rem;
    line-height: 1.45;
    position: relative;
    box-shadow: 0 2px 8px rgba(0,0,0,0.02);
    word-break: break-word;
}

.chat-message.user .message-bubble {
    background: linear-gradient(135deg, #4361ee, #4895ef);
    color: white;
    border-bottom-right-radius: 4px;
}

.chat-message.assistant .message-bubble {
    background: var(--bg-card);
    color: var(--text-main);
    border-bottom-left-radius: 4px;
    border: 1px solid var(--border-color);
}

.chat-message.assistant .message-bubble p {
    margin-bottom: 8px;
}
.chat-message.assistant .message-bubble p:last-child {
    margin-bottom: 0;
}
.chat-message.assistant .message-bubble ul, 
.chat-message.assistant .message-bubble ol {
    margin-left: 20px;
    margin-bottom: 8px;
}
.chat-message.assistant .message-bubble strong {
    font-weight: 600;
}

/* Message Meta & Speaker Action */
.message-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 4px;
    padding: 0 4px;
}

.message-audio-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.7rem;
}

.message-audio-btn:hover {
    color: var(--primary-color);
    background: rgba(67, 97, 238, 0.08);
}

.message-audio-btn.speaking {
    color: var(--success);
    background: rgba(16, 185, 129, 0.08);
    animation: speaker-pulse 1s infinite alternate;
}

@keyframes speaker-pulse {
    0% { transform: scale(1); }
    100% { transform: scale(1.05); }
}

/* Suggestions Area */
.ai-chat-suggestions {
    padding: 0 20px 12px 20px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    background: rgba(248, 250, 252, 0.5);
}

.suggestion-pill {
    background: rgba(67, 97, 238, 0.06);
    border: 1px solid rgba(67, 97, 238, 0.12);
    color: var(--primary-color);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
    max-width: 100%;
}

.suggestion-pill:hover {
    background: var(--primary-color);
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(67, 97, 238, 0.2);
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 10px 14px;
    background: var(--bg-card);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    align-self: flex-start;
    box-shadow: 0 2px 8px rgba(0,0,0,0.02);
}

.typing-dot {
    width: 6px;
    height: 6px;
    background: var(--text-muted);
    border-radius: 50%;
    opacity: 0.4;
    animation: typing-dot-bounce 1.4s infinite;
}

.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing-dot-bounce {
    0%, 100% { transform: translateY(0); opacity: 0.4; }
    50% { transform: translateY(-4px); opacity: 1; }
}

/* Input Area */
.ai-chat-input-area {
    padding: 16px 20px;
    border-top: 1px solid var(--border-color);
    background: var(--bg-card);
    display: flex;
    gap: 12px;
    align-items: center;
}

.ai-chat-input-area input {
    flex: 1;
    border: 1px solid var(--border-color);
    background: var(--bg-main);
    padding: 10px 16px;
    border-radius: 24px;
    font-size: 0.88rem;
    font-family: inherit;
    color: var(--text-main);
    transition: all 0.2s;
}

.ai-chat-input-area input:focus {
    outline: none;
    border-color: var(--primary-color);
    background: white;
    box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.1);
}

.ai-chat-send-btn {
    background: linear-gradient(135deg, #4361ee, #7209b7);
    color: white;
    border: none;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 4px 10px rgba(67, 97, 238, 0.25);
    padding: 0;
}

.ai-chat-send-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 14px rgba(67, 97, 238, 0.35);
}

.ai-chat-send-btn:active {
    transform: scale(0.95);
}

.ai-chat-send-btn i {
    font-size: 0.95rem;
}

