/* ===== BUTTONS ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-xs);
    padding: var(--spacing-sm) var(--spacing-lg);
    font-family: var(--font-family);
    font-size: var(--font-size-base);
    font-weight: 500;
    text-decoration: none;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
    user-select: none;
    min-height: 44px; /* better touch target */
}

/* ===== AI GENERATING OVERLAY ===== */
#aiGeneratingOverlay {
  display: none;
}

#resumeEditorRoot.ai-busy .editor-container {
  filter: blur(2px) saturate(105%);
  transition: filter 0.25s ease;
}

#resumeEditorRoot.ai-busy #aiGeneratingOverlay {
  display: flex !important;
  animation: fadeIn 0.25s ease;
}

/* ===== SKELETON LOADERS ===== */
.skeleton {
  background: linear-gradient(90deg, rgba(0,0,0,0.06), rgba(0,0,0,0.12), rgba(0,0,0,0.06));
  background-size: 200% 100%;
  animation: skeleton-loading 1.2s ease-in-out infinite;
  border-radius: 6px;
}
.skeleton-text { display:inline-block; height: 1em; line-height:1; vertical-align:middle; }
@keyframes skeleton-loading {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.btn:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(4, 143, 150, 0.2);
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Button Variants */
.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}

.btn-secondary {
    background: var(--secondary-color);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover:not(:disabled) {
    background: #eeeeee;
    border-color: #d0d0d0;
}

.btn-outline {
    background: transparent;
    color: var(--primary-color);
    border: 1px solid var(--primary-color);
}

.btn-outline:hover:not(:disabled) {
    background: var(--primary-color);
    color: white;
}

/* Button Sizes */
.btn-sm {
    padding: var(--spacing-xs) var(--spacing-md);
    font-size: var(--font-size-sm);
}

.btn-lg {
    padding: var(--spacing-md) var(--spacing-xl);
    font-size: var(--font-size-lg);
}

/* Button Icons */
.btn-icon {
    font-size: 1.2em;
    line-height: 1;
}

.btn-create {
    font-size: var(--font-size-lg);
    padding: var(--spacing-md) var(--spacing-xl);
}

.btn-filter {
    border: 1px solid var(--border-color);
}

/* ===== MODALS ===== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 2000;
    animation: fadeIn 0.3s ease;
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: var(--background);
    border-radius: var(--border-radius);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    max-width: 95vw;
    max-height: 95vh;
    overflow: hidden;
    animation: slideUp 0.3s ease;
}

/* ===== PROGRESS MODAL (Lottie) ===== */
.progress-modal-content {
  width: min(720px, 96vw);
}
.progress-modal-content .modal-header {
  padding: var(--spacing-xl) var(--spacing-2xl);
}
.progress-modal-content .modal-body {
  padding: var(--spacing-xl) var(--spacing-2xl);
}
.progress-modal-content .modal-footer {
  padding: var(--spacing-md) var(--spacing-xl);
  border-top: 1px solid var(--border-color);
}
.progress-step {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.progress-anim {
  width: clamp(220px, 42vw, 360px);
  height: clamp(220px, 42vw, 360px);
  object-fit: contain;
  display: block;
  margin: 6px auto 0;
  border-radius: 12px;
  box-shadow: 0 6px 24px rgba(0,0,0,.08), inset 0 0 0 1px rgba(255,255,255,.06);
}
.progress-step .step-title {
  font-size: var(--font-size-lg);
  font-weight: 600;
  color: var(--text-primary);
}

/* Subtle gradient background for progress modal */
.progress-modal-content {
  background: linear-gradient(180deg, rgba(255,255,255,0.02), rgba(255,255,255,0.0)), var(--background);
}

/* ===== AI Prompt modal attachment UI ===== */
.ai-prompt-tools {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
}
.attach-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px dashed var(--border-color);
  padding: 8px 12px;
  border-radius: 10px;
  background: rgba(255,255,255,0.03);
  cursor: pointer;
}
.attach-btn:hover { background: rgba(255,255,255,0.06); }
.attach-icon { font-size: 16px; }
.attach-filename { font-size: 12px; opacity: .7; }

.resume-editor-content {
    border-radius: 0;
    box-shadow: none;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--spacing-lg) var(--spacing-xl);
    border-bottom: 1px solid var(--border-color);
    background: var(--background-light);
}

.header-left {
    display: flex;
    align-items: center;
}

.header-right {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    margin-left: auto; /* keep avatar/menu on the far right */
}

/* ===== USER AVATAR MENU ===== */
.user-menu { position: relative; }
.avatar-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: transparent;
    border: 1px solid var(--border-color);
    padding: 4px 10px;
    border-radius: 999px;
    cursor: pointer;
}
.avatar { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; }
.user-name { color: var(--text-primary); font-weight: 600; font-size: 14px; }
.user-dropdown {
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    background: var(--background);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    min-width: 180px;
    box-shadow: 0 10px 30px rgba(0,0,0,.12);
    display: none;
    z-index: 1200;
}
.user-dropdown.open { display: block; }
.dropdown-item {
    display: block;
    padding: 10px 14px;
    color: var(--text-primary);
    text-decoration: none;
}
.dropdown-item:hover { background: var(--secondary-color); }
.dropdown-divider { height: 1px; background: var(--border-color); margin: 4px 0; }

/* ===== AI BUTTON (button2) ===== */
.button2 {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  transition: all 0.2s ease-in;
  position: relative;
  overflow: hidden;
  z-index: 1;
  color: #090909;
  padding: 0.55em 1.4em; /* slightly smaller height */
  cursor: pointer;
  font-size: 16px; /* slightly smaller text */
  border-radius: 0.5em;
  background: #e8e8e8;
  border: 1px solid #e8e8e8;
  box-shadow: 6px 6px 12px #c5c5c5, -6px -6px 12px #ffffff;
}

.button2:active {
  color: #666;
  box-shadow: inset 4px 4px 12px #c5c5c5, inset -4px -4px 12px #ffffff;
}

.button2:before {
  content: "";
  position: absolute;
  left: 50%;
  transform: translateX(-50%) scaleY(1) scaleX(1.25);
  top: 100%;
  width: 140%;
  height: 180%;
  background-color: rgba(0, 0, 0, 0.05);
  border-radius: 50%;
  display: block;
  transition: all 0.5s 0.1s cubic-bezier(0.55, 0, 0.1, 1);
  z-index: -1;
}

.button2:after {
  content: "";
  position: absolute;
  left: 55%;
  transform: translateX(-50%) scaleY(1) scaleX(1.45);
  top: 180%;
  width: 160%;
  height: 190%;
  background-color: #009087;
  border-radius: 50%;
  display: block;
  transition: all 0.5s 0.1s cubic-bezier(0.55, 0, 0.1, 1);
  z-index: -1;
}

.button2:hover {
  color: #ffffff;
  border: 1px solid #009087;
}

.button2:hover:before {
  top: -35%;
  background-color: #009087;
  transform: translateX(-50%) scaleY(1.3) scaleX(0.8);
}

.button2:hover:after {
  top: -45%;
  background-color: #009087;
  transform: translateX(-50%) scaleY(1.3) scaleX(0.8);
}

/* Loading state */
.button2.is-loading {
  pointer-events: none;
  opacity: 0.9;
}
.button2 .ai-label { position: relative; z-index: 2; }
.button2 .ai-icon {
  /* 10% bigger than original 18px -> ~20px */
  width: 20px;
  height: 20px;
  display: inline-block;
  flex: 0 0 20px;
  position: relative;
  z-index: 2;
}
.button2 .ai-spinner {
  display: none;
  width: 18px; height: 18px;
  border: 2px solid rgba(255,255,255,0.6);
  border-top-color: #fff;
  border-radius: 50%;
  animation: ai-spin 0.8s linear infinite;
  margin-left: 10px;
}
.button2.is-loading .ai-spinner { display: inline-block; }
@keyframes ai-spin { to { transform: rotate(360deg); } }

/* Improve contrast for icon on hover (when button text turns white) */
.button2:hover .ai-icon {
  filter: brightness(0) invert(1);
}

/* Mini variant for inline textarea AI buttons */
.button2.button2-mini {
  padding: 6px 10px;
  font-size: 13px;
  border-radius: 10px;
  box-shadow: 4px 4px 10px #c5c5c5, -4px -4px 10px #ffffff;
}
.button2.button2-mini .ai-icon { width: 16px; height: 16px; flex: 0 0 16px; }
.button2.button2-mini .ai-spinner { width: 14px; height: 14px; }

/* Textarea AI wrap positions the mini button at bottom-right */
.textarea-ai-wrap { position: relative; }
.textarea-ai-wrap textarea.form-textarea { padding-right: 88px; }
.textarea-ai-wrap .ai-mini {
  position: absolute;
  right: 10px;
  bottom: 10px;
  z-index: 2;
}

/* ===== HEADER CREDITS PILL ===== */
.credits-wrap { display:flex; align-items:center; gap:10px; margin-right: 8px; }
.credits-pill {
  background: #e8f7f8;
  color: #04666b;
  border: 1px solid #bfeaec;
  padding: 6px 10px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 13px;
}
.upgrade-link {
  color: var(--primary-color);
  text-decoration: none;
  font-weight: 600;
  border: 1px solid var(--primary-color);
  padding: 6px 10px;
  border-radius: 999px;
}
.upgrade-link:hover { background: var(--primary-color); color: #fff; }

.preview-label {
    font-size: var(--font-size-lg);
    font-weight: 600;
    color: var(--text-primary);
    margin-right: var(--spacing-md);
}

/* ===== SAVE BUTTON STATES ===== */
.btn.saving {
    background: #f39c12;
    color: white;
}

.btn.saved {
    background: #27ae60;
    color: white;
}

.spinner {
    display: inline-block;
    width: 12px;
    height: 12px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 0.8s ease-in-out infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.modal-title {
    font-size: var(--font-size-xl);
    font-weight: 600;
    color: var(--text-primary);
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-secondary);
    padding: var(--spacing-xs);
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.modal-close:hover {
    background: var(--secondary-color);
    color: var(--text-primary);
}

/* ===== FLOATING CLOSE BUTTON ===== */
.floating-close {
    position: fixed;
    top: 08px;
    right: 20px;
    width: 30px;
    height: 30px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 50%;
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
    z-index: 2001;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(4, 143, 150, 0.3);
    transition: all 0.3s ease;
}

.floating-close:hover {
    background: var(--primary-dark);
    transform: scale(1.1);
    box-shadow: 0 6px 25px rgb(4, 143, 150);
}

/* ===== FULLSCREEN FUNCTIONALITY ===== */
.fullscreen-toggle {
    padding: var(--spacing-sm) var(--spacing-md);
    min-width: 44px;
}

.fullscreen-icon {
    font-size: 16px;
    display: inline-block;
}

.fullscreen-fallback {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    z-index: 9999 !important;
}

.modal.fullscreen-fallback .modal-content {
    width: 100vw !important;
    height: 100vh !important;
    border-radius: 0 !important;
}

/* Hide floating close button in fullscreen */
.modal:fullscreen .floating-close,
.modal.fullscreen-fallback .floating-close {
    display: none;
}

/* ===== RESUME EDITOR ===== */
.resume-editor-content {
    /* Let the page-specific styles in editor.php control sizing */
    width: 100%;
    height: auto;
    display: flex;
    flex-direction: column;
}

.editor-container {
    display: flex;
    flex: 1;
    /* Allow child panels to manage their own scrolling */
    overflow: visible;
}

.editor-sidebar {
    /* Width and min-width are handled in editor.php */
    background: var(--background-light);
    border-right: 1px solid var(--border-color);
    overflow-y: auto;
}

.editor-form {
    padding: var(--spacing-xl);
    max-width: none;
}

.editor-preview {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--background);
}

/* Removed preview-header styles as they're now in main header */

.preview-content {
    flex: 1;
    padding: var(--spacing-xl);
    overflow-y: auto;
    background: #f8f9fa;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

/* ===== Resume page sizing (screen) ===== */
#editorPreview .resume-template {
  width: 100%;
  max-width: 800px;
  margin: 0 auto;
  background: #fff;
  box-shadow: 0 -4px 8px rgba(0,0,0,0.1), 0 4px 8px rgba(0,0,0,0.1);
  border-radius: 4px;
}

/* AI Improve Button */
.ai-improve-button {
  position: absolute;
  top: 10px;
  right: 60px;
  z-index: 10;
}

.ai-improve-button .ai-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  font-size: 14px;
  border-radius: 8px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border: none;
  color: white;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.ai-improve-button .ai-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.ai-improve-button .ai-icon {
  fill: currentColor;
  flex-shrink: 0;
}

/* AI Improve Modal */
.ai-improve-modal {
  max-width: 600px;
  width: 90vw;
}

.ai-improve-modal .modal-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.ai-improve-modal .modal-title .ai-icon {
  fill: #667eea;
}

.ai-improve-intro {
  background: #f8fafc;
  padding: 16px;
  border-radius: 8px;
  margin-bottom: 20px;
  border-left: 4px solid #667eea;
}

.ai-improve-intro p {
  margin: 0;
  color: #4a5568;
  font-size: 14px;
  line-height: 1.5;
}

.improve-sections {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-top: 8px;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 14px;
}

.checkbox-label:hover {
  background: #edf2f7;
  border-color: #cbd5e0;
}

.checkbox-label input[type="checkbox"] {
  margin: 0;
}

.checkbox-label input[type="checkbox"]:checked + span,
.checkbox-label:has(input[type="checkbox"]:checked) {
  background: #667eea;
  color: white;
  border-color: #667eea;
}


/* Avoid awkward splits inside key blocks when printed */
#editorPreview .resume-header,
#editorPreview .resume-section,
#editorPreview .row.two,
#editorPreview .resume-details,
#editorPreview .skills-grid {
  break-inside: avoid;
  page-break-inside: avoid;
}

/* ===== Print pagination ===== */
@media print {
  @page { size: A4; margin: 12mm; }
  body { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  #editorPreviewPanel, #editorPreview, .preview-content { background: #fff !important; }
  /* Remove UI chrome/shadows/borders in print */
  #editorPreview .resume-template { box-shadow: none !important; border: 0 !important; width: auto !important; margin: 0 !important; }
  /* Keep sections intact across pages */
  #editorPreview .resume-header,
  #editorPreview .resume-section,
  #editorPreview .row.two,
  #editorPreview .resume-details,
  #editorPreview .skills-grid {
    break-inside: avoid;
    page-break-inside: avoid;
  }
}

.preview-content.updating {
    opacity: 0.7;
    transform: scale(0.98);
}

.preview-content.updated {
    animation: previewUpdate 0.4s ease;
}

@keyframes previewUpdate {
    0% {
        opacity: 0.7;
        transform: scale(0.98);
    }
    50% {
        opacity: 0.9;
        transform: scale(1.01);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

/* ===== FORMS ===== */
.form-section {
    margin-bottom: var(--spacing-2xl);
}

.form-section-title {
    font-size: var(--font-size-lg);
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--spacing-lg);
    padding-bottom: var(--spacing-sm);
    border-bottom: 2px solid var(--primary-color);
}

.form-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-lg);
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--spacing-md);
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group-full {
    grid-column: 1 / -1;
}

.form-label {
    font-size: var(--font-size-sm);
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: var(--spacing-xs);
}

.form-input,
.form-textarea,
.form-select {
    padding: var(--spacing-sm) var(--spacing-md);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    font-family: var(--font-family);
    font-size: var(--font-size-base);
    color: var(--text-primary);
    background: var(--background);
    transition: var(--transition);
}

.form-input:focus,
.form-textarea:focus,
.form-select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(4, 143, 150, 0.1);
}

.form-textarea {
    resize: vertical;
    min-height: 80px;
}

/* ===== DYNAMIC LISTS ===== */
.dynamic-list {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-lg);
}

.dynamic-item {
    background: var(--background);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: var(--spacing-lg);
    position: relative;
}

.dynamic-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-md);
}

.dynamic-item-title {
    font-size: var(--font-size-base);
    font-weight: 500;
    color: var(--text-primary);
}

.dynamic-item-remove {
    background: none;
    border: none;
    color: #e74c3c;
    font-size: 18px;
    cursor: pointer;
    padding: var(--spacing-xs);
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.dynamic-item-remove:hover {
    background: rgba(231, 76, 60, 0.1);
}

/* Mobile preview trigger hidden by default (desktop) */
.mobile-preview-trigger { display: none; }

/* ===== SKILL ITEMS ===== */
.skill-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    background: var(--background);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: var(--spacing-md);
}

.skill-name {
    flex: 1;
}

.skill-level {
    width: 120px;
}

.skill-remove {
    background: none;
    border: none;
    color: #e74c3c;
    cursor: pointer;
    padding: var(--spacing-xs);
}

/* ===== ANIMATIONS ===== */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

/* ===== RESPONSIVE ===== */
@media (max-width: 1024px) {
    .editor-container {
        flex-direction: column;
    }
    
    .editor-sidebar {
        width: 100%;
        min-width: 0;
        /* Remove restrictive 50vh cap to prevent cut-off */
        max-height: none;
    }
}

@media (max-width: 768px) {
    /* Allow button text to wrap and avoid overflow */
    .btn { white-space: normal; text-align: center; }
    
    .form-grid {
        grid-template-columns: 1fr;
    }
    
    .modal-content {
        width: 100%;
        height: 100%;
        border-radius: 0;
    }
    
    .editor-form {
        padding: var(--spacing-lg);
    }
    
    .modal-header {
        flex-direction: column;
        align-items: stretch;
        gap: var(--spacing-md);
        padding: var(--spacing-md);
    }
    
    .header-left,
    .header-right {
        justify-content: center;
    }
    
    .header-right {
        flex-wrap: wrap;
        gap: var(--spacing-sm);
    }
    
    .preview-label {
        margin-right: 0;
        order: -1;
    }

    /* Defer mobile panel visibility to tab logic in editor.php */
    /* Preview/sidebar visibility is controlled via [data-tab] on #resumeEditorRoot */

    /* Preview sizing optimization */
    #editorPreviewPanel { height: auto; }
    #editorPreviewPanel .preview-content { padding: 12px; }

    /* Show mobile preview trigger on small screens */
    .mobile-preview-trigger { display: block; }

    /* In-preview mobile bar */
    .mobile-preview-bar {
        position: sticky;
        top: 0;
        z-index: 5;
        background: #ffffffcc;
        backdrop-filter: blur(6px);
        border: 1px solid var(--border-color);
        border-radius: 10px;
        padding: 8px;
        margin-bottom: 8px;
        display: flex;
        align-items: center;
        gap: 8px;
    }
    .mobile-preview-bar .btn { padding: 6px 10px; font-size: 13px; }

    /* Override resume template paddings inside preview for mobile */
    #editorPreview .resume-template { box-shadow: none !important; }
    #editorPreview .resume-header { padding: 1rem !important; }
    #editorPreview .resume-content { flex-direction: column !important; min-height: auto !important; }
    #editorPreview .resume-left, #editorPreview .resume-right { width: 100% !important; padding: 1rem !important; border-right: 0 !important; }

    /* Header compact: hide name; show credits icon and only the number and + button */
    .header .user-name { display: none !important; }
    .header #creditsPill { display: inline-flex !important; align-items: center; padding: 2px 6px; line-height: 1.2; border-radius: 8px; }
    /* Hide text inside pill and render only number via ::before from data-credits */
    .header #creditsPill { font-size: 0; }
    .header #creditsPill::before { content: attr(data-credits); font-size: 12px; }
    .header #creditsWrap { gap: 6px !important; }
    .header #creditsIcon { width: 18px; height: 18px; }
    .header .credits-plus { width: 28px; height: 28px; font-size: 16px; }

    /* AI modal: keep Generate with AI button full width on mobile */
    .ai-modal-content .ai-actions { display: flex; flex-wrap: wrap; gap: 8px; }
    .ai-modal-content .ai-actions .button { flex: 1 1 100%; width: 100%; }
    .ai-modal-content .ai-actions .ai-mic-btn { flex: 0 0 auto; }

    /* Tone down hover transforms on mobile for performance */
    .resume-card:hover { transform: none; }
    .resume-preview-image { transition: none; }
}

/* ===== DASHBOARD TOOLBAR ===== */
.dashboard-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--spacing-md);
    margin: var(--spacing-lg) 0;
}
.dashboard-toolbar .toolbar-left { display: flex; align-items: center; gap: var(--spacing-sm); }
.dashboard-toolbar .toolbar-right { display: flex; align-items: center; gap: var(--spacing-sm); }

/* Hide dashboard credits icon only (header icon stays visible) */
#dashCreditsIcon { display: none !important; }

/* Create New Resume button: smaller and tidy */
.btn.btn-primary.btn-create {
    padding: 6px 10px;
    font-size: 15px;
    line-height: 1.2;
    border-radius: 8px;
}
/* reduce plus icon bubble */
.dashboard-toolbar .toolbar-left { display: flex; align-items: center; gap: var(--spacing-sm); }
.dashboard-toolbar .toolbar-right { display: flex; align-items: center; gap: var(--spacing-sm); }

/* ===== WELCOME ROW (top of dashboard) ===== */
.welcome-row { gap: 16px; }
.welcome-actions { display: flex; align-items: center; }
.welcome-actions .button { margin: 0; }

@media (max-width: 768px) {
    .dashboard-toolbar { gap: 8px; }
    .dashboard-toolbar .toolbar-left { flex: 1 1 auto; min-width: 0; }
    .dashboard-toolbar .toolbar-right { flex: 0 0 auto; }
    /* Keep dashboard AI button text visible on mobile */
    .dashboard-toolbar .button .btn-text { display: inline !important; }
    .dashboard-toolbar .button { white-space: nowrap; max-width: 100%; }

    /* Welcome row: left-align AI button on mobile; keep text visible */
    .welcome-row { flex-wrap: wrap; }
    .welcome-actions { width: 100%; justify-content: flex-start; }
    .welcome-actions .button .btn-text { display: inline !important; }

    /* Remove legacy mobile editor sizing that conflicts with editor.php */
    .resume-editor-content { width: 100%; max-width: none; height: auto; margin: 0; border-radius: 12px; display: flex; flex-direction: column; }
    .resume-editor-content .editor-container { flex: 1 1 auto; min-height: 0; display: block; padding: 8px 12px; }
    .resume-editor-content .editor-sidebar { width: 100%; }
    .resume-editor-content .editor-sidebar .editor-form { overflow: auto; max-height: none; padding-bottom: 16px; }
}

/* ===== QUALITY DIALOG ===== */
.quality-dialog-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 3000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.quality-dialog-overlay.active {
    opacity: 1;
}

.quality-dialog {
    background: var(--background);
    border-radius: var(--border-radius);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    max-width: 450px;
    width: 90vw;
    transform: scale(0.9) translateY(20px);
    transition: transform 0.3s ease;
}

.quality-dialog-overlay.active .quality-dialog {
    transform: scale(1) translateY(0);
}

.quality-dialog-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--spacing-lg) var(--spacing-xl);
    border-bottom: 1px solid var(--border-color);
}

.quality-dialog-header h3 {
    margin: 0;
    font-size: var(--font-size-xl);
    font-weight: 600;
    color: var(--text-primary);
}

.dialog-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-secondary);
    padding: var(--spacing-xs);
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.dialog-close:hover {
    background: var(--secondary-color);
    color: var(--text-primary);
}

.quality-dialog-content {
    padding: var(--spacing-xl);
}

.quality-dialog-content p {
    margin: 0 0 var(--spacing-lg) 0;
    color: var(--text-secondary);
}

.quality-options {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
}

.quality-option {
    display: flex;
    align-items: center;
    padding: var(--spacing-lg);
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--transition);
    background: var(--background);
}

.quality-option.resume-card:hover {
    box-shadow: var(--shadow);
    transform: translateY(-2px);
}

.quality-icon {
    font-size: 2rem;
    margin-right: var(--spacing-lg);
    min-width: 60px;
    text-align: center;
}

.quality-info h4 {
    margin: 0 0 var(--spacing-xs) 0;
    font-size: var(--font-size-lg);
    font-weight: 600;
    color: var(--text-primary);
}

.quality-info p {
    margin: 0;
    font-size: var(--font-size-sm);
    color: var(--text-light);
}

/* ===== CUSTOM DATE PICKER ===== */
.custom-date-picker,
.custom-month-picker {
    position: relative;
}

.date-display,
.month-display {
    width: 100%;
    padding: var(--spacing-sm) var(--spacing-md);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    font-family: var(--font-family);
    font-size: var(--font-size-base);
    color: var(--text-primary);
    background: var(--background);
    cursor: pointer;
    transition: var(--transition);
}

.date-display:focus,
.month-display:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(4, 143, 150, 0.1);
}

.date-picker-dropdown,
.month-picker-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--background);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    z-index: 1000;
    display: none;
    margin-top: 4px;
}

.date-picker-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--spacing-md);
    border-bottom: 1px solid var(--border-color);
}

.date-picker-title {
    font-weight: 600;
    color: var(--text-primary);
}

.date-nav {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: var(--text-secondary);
    padding: var(--spacing-xs);
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.date-nav:hover {
    background: var(--secondary-color);
    color: var(--text-primary);
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 1px;
    padding: var(--spacing-sm);
}

.calendar-header {
    padding: var(--spacing-sm);
    text-align: center;
    font-size: var(--font-size-xs);
    font-weight: 600;
    color: var(--text-secondary);
}

.calendar-day {
    padding: var(--spacing-sm);
    text-align: center;
    cursor: pointer;
    border-radius: 4px;
    transition: var(--transition);
    font-size: var(--font-size-sm);
}

.calendar-day:not(.empty):hover {
    background: var(--primary-color);
    color: white;
}

.calendar-day.empty {
    cursor: default;
}

.month-year-selector {
    padding: var(--spacing-md);
    display: flex;
    gap: var(--spacing-sm);
    align-items: center;
}

.month-select,
.year-select {
    flex: 1;
    padding: var(--spacing-sm);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    font-family: var(--font-family);
    font-size: var(--font-size-sm);
    color: var(--text-primary);
    background: var(--background);
}

.present-btn {
    padding: var(--spacing-sm) var(--spacing-md);
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--border-radius);
    font-size: var(--font-size-sm);
    cursor: pointer;
    transition: var(--transition);
}

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

/* ===== AI PROMPT MODAL ===== */
.ai-modal-content {
    width: min(900px, 96vw);
}

.ai-modal-content .modal-header {
    padding: var(--spacing-lg) var(--spacing-xl);
}

.ai-modal-body {
    padding: var(--spacing-xl);
}

.ai-prompt-label {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
}

.ai-chat-input {
    width: 100%;
    min-height: 180px;
    resize: vertical;
    padding: 16px 18px;
    border-radius: 14px;
    border: 1px solid var(--border-color);
    background: var(--background);
    font-size: 15px;
    line-height: 1.55;
    outline: none;
    transition: box-shadow 150ms ease, border-color 150ms ease, background 150ms ease;
}

.ai-chat-input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(4, 143, 150, 0.12);
    background: #fff;
}
.ai-hint {
    margin-top: 10px;
    color: var(--text-secondary);
    font-size: 15px;
    
}


.ai-hint1 {
    margin-top: 10px;
    color: var(--text-secondary);
    font-size: 20px;
    font-weight: 600;
}

.ai-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    align-items: center;
    margin-top: 6px;
}

/* ===== AI Microphone Button ===== */
.ai-mic-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  min-height: 44px;
  border-radius: 999px;
  border: 1px solid var(--border-color);
  background: var(--background);
  color: var(--text-primary);
  cursor: pointer;
  transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
}
.ai-mic-btn:hover { transform: translateY(-1px); box-shadow: 0 6px 18px rgba(0,0,0,.08); }
.ai-mic-btn.active { border-color: #e11d48; background: #fff0f3; }
.ai-mic-btn .mic-icon { font-size: 16px; line-height: 1; }
.ai-mic-btn .mic-label { font-weight: 600; font-size: 14px; }

.mic-pulse {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  pointer-events: none;
  box-shadow: 0 0 0 0 rgba(225, 29, 72, 0.35);
  animation: none;
}
.ai-mic-btn.active .mic-pulse { animation: mic-pulse 1.5s ease-out infinite; }
@keyframes mic-pulse {
  0% { box-shadow: 0 0 0 0 rgba(225, 29, 72, 0.35); }
  70% { box-shadow: 0 0 0 12px rgba(225, 29, 72, 0); }
  100% { box-shadow: 0 0 0 0 rgba(225, 29, 72, 0); }
}

.mic-status { font-size: 13px; color: var(--text-secondary); min-height: 1em; }

/* =====ai button (replaces old AI button style) ===== */
.button {
  position: relative;
  transition: all 0.3s ease-in-out;
  box-shadow: 0px 10px 20px rgba(0, 0, 0, 0.2);
  padding-block: 0.5rem;
  padding-inline: 1.25rem;
  background-color: #048f96;
  border-radius: 9999px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  gap: 10px;
  font-weight: bold;
  border: 3px solid #ffffff4d;
  outline: none;
  overflow: hidden;
  font-size: 15px;
  cursor: pointer;
}

/* Mini variant for compact contexts (inside inputs) */
.button.button--mini {
  padding-block: 0.25rem;
  padding-inline: 0.6rem;
  font-size: 13px;
  gap: 6px;
  border-width: 2px;
  box-shadow: 0 4px 10px rgba(0,0,0,0.15);
}
.button.button--mini .icon { width: 16px; height: 26px; }
.button .btn-text { display: inline-flex; align-items: center; }

/* Inline AI button removed; revert textarea defaults */

.icon {
  width: 24px;
  height: 24px;
  transition: all 0.3s ease-in-out;
}

.button:hover {
  transform: scale(1.05);
  border-color: #fff9;
  background-color: #03787e;
}

.button:hover .icon {
  transform: translate(4px);
}

.button:hover::before {
  animation: shine 1.5s ease-out infinite;
}

.button::before {
  content: "";
  position: absolute;
  width: 100px;
  height: 100%;
  background-image: linear-gradient(
    120deg,
    rgba(255, 255, 255, 0) 30%,
    rgba(255, 255, 255, 0.8),
    rgba(255, 255, 255, 0) 70%
  );
  top: 0;
  left: -100px;
  opacity: 0.6;
}

@keyframes shine {
  0% {
    left: -100px;
  }

  60% {
    left: 100%;
  }

  to {
    left: 100%;
  }
}

/* =================== Responsive (Mobile-first overrides) =================== */
@media (max-width: 768px) {
  /* Generic modal container adjustments */
  .modal .modal-content {
    width: 95%;
    max-width: 560px;
    padding: 14px 14px 16px;
  }
  .modal .modal-header { padding: 6px 4px; }
  .modal .modal-body { padding: 8px 0; }

  /* AI modal specifics */
  .ai-prompt-label { font-size: 14px; }
  .ai-chat-input { min-height: 140px; font-size: 14px; }
  .ai-hint { font-size: 13px; }
  .ai-actions { gap: 8px; justify-content: space-between; }
  #aiMicBtn.ai-mic-btn { padding: 8px 12px; min-height: 40px; }
  #aiMicBtn .mic-label { font-size: 13px; }
  .button { padding-block: 0.45rem; padding-inline: 1rem; font-size: 14px; }
  .button .icon { width: 20px; height: 20px; }

  /* Templates grid/cards */
  #templatesGrid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0,1fr));
    gap: 10px;
  }
  #templatesGrid .tpl-card { padding: 8px; }
  #templatesGrid .tpl-thumb-img { height: auto; }
  #templatesGrid .tpl-meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
  #templatesGrid .tpl-meta .name { font-size: 14px; }
  #templatesGrid [data-choose].btn,
  #templatesGrid [data-choose].button,
  #templatesGrid [data-choose] {
    padding: 6px 10px;
    font-size: 13px;
  }
}

@media (max-width: 480px) {
  /* Stack AI actions when cramped */
  .ai-actions { flex-wrap: wrap; gap: 8px; }
  #aiMicBtn { order: 0; }
  #aiGenerateBtn { flex: 1 1 auto; min-width: 60%; }

  /* Compact microphone button */
  .ai-mic-btn { gap: 6px; padding: 8px 10px; min-height: 38px; }
  .ai-mic-btn .mic-icon { width: 16px; height: 16px; }
  .ai-mic-btn .mic-label { font-size: 12px; }

  /* Compact main action button on very narrow screens */
  .button { padding-block: 0.4rem; padding-inline: 0.9rem; font-size: 13.5px; }
  .button .icon { width: 18px; height: 18px; }
  /* Force welcome button text to stay visible even on xs */
  .welcome-actions .button .btn-text { display: inline !important; }

  /* Templates grid to single column on extra small */
  #templatesGrid { grid-template-columns: 1fr; }
}

@media (max-width: 360px) {
  /* Icon-forward buttons to save space */
  .button .btn-text { display: none; }
  .button { padding-inline: 0.8rem; }
  #aiMicBtn .mic-label { display: none; }
}
/* Remove focus outline completely */
*:focus {
    outline: none !important;
    box-shadow: none !important;
}

/* Remove mobile tap highlight (iOS/Android) */
* {
    -webkit-tap-highlight-color: transparent; /* removes blue flash on tap */
    -webkit-touch-callout: none;             /* disables long press menu on iOS */
    -webkit-user-select: none;               /* optional: disables text selection */
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}
