/* Lead Genie Main CSS - Enhanced for All Forms with 12px Desktop Table Fonts */

/* ====================================================================
   BASE STYLES & RESET
   ====================================================================*/
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

img { max-width: 100%; height: auto; }

/* Prevent FOUC (Flash of Unstyled Content) */
.loading { visibility: hidden; }

body {
    background-color: #f8f9fa;
    min-height: 100vh;
    font-family: Calibri, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    padding: 15px;
    position: relative;
    overflow-x: hidden;
    overflow-y: auto;
    line-height: 1.4;
}

/* Add left margin for desktop layouts */
@media screen and (min-width: 769px) {
    body {
        padding-left: 40px;
        padding-right: 20px;
    }
}


/* ====================================================================
   GLOBAL FORM STYLES
   ====================================================================*/

/* Form containers */
.form-container, 
.page-container {
    display: flex;
    flex-direction: column;
    min-height: calc(100vh - 30px);
    align-items: center;
    position: relative;
    z-index: 10;
}

/* Form wrapper for desktop centering */
.login-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
    width: 100%;
    min-height: 0;
}

/* Main form containers */
.login-container, 
.box {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(15px);
    border-radius: 20px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
    padding: 2rem 1.5rem;
    width: 100%;
    max-width: 420px;
    text-align: center;
    position: relative;
    z-index: 10;
    overflow: hidden;
    margin: auto;
}

/* Box styles for application forms */
.box {
    background-color: #f2f2f2;
    border-radius: 15px;
    border: 2px solid lightblue;
    padding: 15px;
    margin-bottom: 20px;
    text-align: left;
    max-width: none;
}

.boxFullWidth {
    background-color: #f2f2f2;
    border-radius: 15px;
    border: 2px solid lightblue;
    padding: 15px;
    margin-bottom: 20px;
    width: 100%;
}

.login-container::before,
.box::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(45deg, #667eea, #764ba2);
}

/* ====================================================================
   FORM ELEMENTS - GLOBAL IMPROVEMENTS
   ====================================================================*/

/* Labels */
label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: #2c3e50;
    font-size: 1rem;
}
 
/* Form groups */
.form-group {
    margin-bottom: 1.25rem;
    text-align: left;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: #2c3e50;
    font-size: 1rem;
}

/* INPUT FIELDS - REDUCED HEIGHT AND IMPROVED STYLING */
.form-control,
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="tel"],
input[type="url"],
input[type="date"],
select {
    width: 100%;
    padding: 0.6rem 1rem;
    border: 2px solid #e9ecef;
    border-radius: 10px;
    font-size: 14px;
    height: 38px;
    transition: all 0.3s ease;
    background: #fff;
    box-sizing: border-box;
    font-family: inherit;
}

/* Mobile-specific input sizing */
@media screen and (max-width: 768px) {
    .form-control,
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="number"],
    input[type="tel"],
    input[type="url"],
    input[type="date"],
    select {
        font-size: 16px;
        height: 44px;
        padding: 0.75rem 1rem;
    }
}

/* Non-table input height normalization */
input:not([type="checkbox"]):not(.leads-table input):not(.campaigns-table input),
select:not(.leads-table select):not(.campaigns-table select) {
    height: 32px !important;
    padding: 6px 10px !important;
}

input[type="checkbox"] {
    height: 16px !important;
    width: 16px !important;
    padding: 0 !important;
    margin: 0 !important;
}

/* Non-table inputs: enforce 16px for mobile zoom prevention + touch */
input:not(.leads-table input):not(.campaigns-table input),
textarea:not(.leads-table textarea):not(.campaigns-table textarea),
select:not(.leads-table select):not(.campaigns-table select) {
    font-size: 16px;
    border-radius: 4px;
}

/* Focus states */
.form-control:focus,
input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* Textarea styling */
textarea {
    width: 100%;
    min-height: 80px;
    padding: 0.75rem 1rem;
    border: 2px solid #e9ecef;
    border-radius: 10px;
    font-size: 14px;
    resize: vertical;
    font-family: inherit;
    line-height: 1.4;
    box-sizing: border-box;
}

textarea.auto-resize {
    resize: both;
}

@media screen and (max-width: 768px) {
    textarea {
        font-size: 16px;
        min-height: 100px;
    }
}

/* Checkbox and radio styling */
input[type="checkbox"],
input[type="radio"] {
    width: 18px;
    height: 18px;
    margin-right: 0.5rem;
    accent-color: #667eea;
}

/* Password container with eye icon */
.password-container {
    position: relative;
}

.password-toggle,
.password-toggle-btn {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    color: #6c757d;
    font-size: 1rem;
    padding: 0.25rem;
    transition: color 0.3s ease;
    z-index: 5;
}

.password-toggle:hover,
.password-toggle-btn:hover {
    color: #667eea;
}

/* ====================================================================
   BUTTON STYLES
   ====================================================================*/

/* Base button styles */
.btn,
button,
input[type="submit"],
input[type="button"] {
    padding: 0.6rem 1.2rem;
    border: none;
    border-radius: 10px;
    font-family: inherit;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-bottom: 1rem;
    text-decoration: none;
    display: inline-block;
    text-align: center;
    box-sizing: border-box;
    min-height: 44px;
    min-width: 44px;
}

/* Touch targets for non-table buttons */
button:not(.leads-table button):not(.campaigns-table button),
input[type="submit"]:not(.leads-table input):not(.campaigns-table input),
input[type="button"]:not(.leads-table input):not(.campaigns-table input) {
    min-height: 44px;
    min-width: 44px;
    touch-action: manipulation;
}

/* Rounded button style (application specific) */
.rounded {
    border: 2px solid #007bff;
    border-radius: 20px;
    padding: 0.5rem 1rem;
    margin: 0.25rem;
    cursor: pointer;
    font-size: 16px;
    background: white;
    color: #007bff;
    transition: all 0.3s ease;
    min-width: 80px;
    height: auto;
}

.rounded:hover {
    background: #f8f9fa;
    transform: translateY(-1px);
}

.rounded.selected {
    background-color: #007bff !important;
    color: white !important;
}

/* Primary button */
.btn-primary {
    background: linear-gradient(45deg, #667eea, #764ba2);
    color: white;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.4);
}

/* Secondary button */
.btn-secondary {
    background: #f8f9fa;
    color: #6c757d;
    border: 2px solid #e9ecef;
}

.btn-secondary:hover {
    background: #e9ecef;
    color: #495057;
    transform: translateY(-1px);
}

/* Button link */
.btn-link {
    background: none;
    color: #667eea;
    text-decoration: none;
    font-weight: 500;
    font-size: 0.85rem;
    padding: 0.5rem;
}

.btn-link:hover {
    color: #5a6fd8;
    text-decoration: underline;
}

/* ====================================================================
   TABLE STYLES - 12px FONT FOR DESKTOP - UNIFIED
   ====================================================================*/

/* Base table styling - applies to ALL tables */
table {
    border-collapse: collapse !important;
    border-spacing: 0 !important;
    width: 100%;
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    margin-bottom: 20px;
}

/* Desktop table styling - 12px font */
@media screen and (min-width: 769px) {
    table th, 
    table td {
        padding: 2px 4px !important;
        height: auto !important;
        min-height: 14px !important;
        font-size: 16px !important;
        line-height: 1.2 !important;
        vertical-align: middle !important;
        border: 1px solid #ddd !important;
        box-sizing: border-box !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        white-space: nowrap !important;
    }

    table tr {
        height: 18px !important;
        max-height: 18px !important;
        min-height: 18px !important;
    }
    
    /* Desktop table buttons - separate class for table-specific buttons */
    table .table-btn {
        border: none !important;
        border-radius: 4px !important;
        padding: 0px 10px !important;
        margin: 0px 2px !important;
        cursor: pointer !important;
        font-size: 12px !important;
        background: #007bff !important;
        color: white !important;
        transition: all 0.3s ease !important;
        min-width: 40px !important;
        height: 10px !important;
        line-height: 1 !important;
        display: inline-block !important;
        vertical-align: middle !important;
        box-sizing: border-box !important;
        white-space: nowrap !important;
        text-align: center !important;
        font-weight: normal !important;
    }

    table .table-btn:hover {
        background: #0056b3 !important;
        transform: translateY(-1px) !important;
    }

    table .table-btn-secondary {
        background: #6c757d !important;
        color: white !important;
    }
    table .table-btn-secondary:hover {
        background: #545b62 !important;
    }

    table .table-btn-warning {
        background: #fd7e14 !important;
        color: white !important;
    }
    table .table-btn-warning:hover {
        background: #e06c00 !important;
    }

    table .table-btn-danger {
        background: #dc3545 !important;
        color: white !important;
    }
    table .table-btn-danger:hover {
        background: #c82333 !important;
    }

    table .table-btn.selected {
        background-color: #0056b3 !important;
        color: white !important;
    }

    table .rounded:hover {
        background: #f8f9fa !important;
        transform: translateY(-1px) !important;
    }

    table .rounded.selected {
        background-color: #007bff !important;
        color: white !important;
    }
    
    /* Desktop action cells */
    table td[style*="white-space: nowrap"] {
        padding: 4px 6px !important;
        height: auto !important;
        min-height: 20px !important;
        overflow: visible !important;
        white-space: nowrap !important;
        vertical-align: middle !important;
    }

    /* Desktop forms in tables */
    table form {
        margin: 0 !important;
        padding: 0 !important;
        display: inline !important;
        line-height: 1.2 !important;
        height: auto !important;
    }

    /* Desktop inputs in tables */
    table input {
        border: none !important;
        width: 100% !important;
        text-align: left !important;
        padding: 2px 4px !important;
        font-size: 14px !important;
        height: auto !important;
        margin: 0 !important;
        line-height: 1.2 !important;
        box-sizing: border-box !important;
    }

    table input[type="hidden"] {
        display: none !important;
    }

    /* Desktop text inputs in form tables get proper styling */
    table input[type="text"] {
        border: 1px solid #ccc !important;
        padding: 4px 6px !important;
        font-size: 14px !important;
        background: white !important;
        border-radius: 4px;
        height: 28px !important;
    }
}

/* Mobile table styling - keep compact for mobile */
@media screen and (max-width: 768px) {
    table th, 
    table td {
        padding: 8px 4px !important;
        height: auto !important;
        font-size: 16px !important;
        line-height: 1.3 !important;
        vertical-align: middle !important;
        border: 1px solid #ddd !important;
        box-sizing: border-box !important;
        white-space: normal !important;
    }
    
    /* Mobile table buttons - larger for touch */
    table .rounded {
        padding: 6px 10px !important;
        font-size: 16px !important;
        min-height: 32px !important;
        height: auto !important;
        width: 100% !important;
        margin: 2px 0 !important;
        display: block !important;
    }
    
    /* Mobile table styling - stack cards */
    table thead {
        display: none;
    }
    
    table,
    table tbody,
    table tr,
    table td {
        display: block;
        width: 100%;
    }
    
    table tr {
        margin-bottom: 15px;
        padding: 15px;
        background: white;
        border-radius: 8px;
        border: 1px solid #ddd;
    }
    
    table td {
        position: relative;
        padding: 10px 0;
        border: none;
        text-align: left;
    }
    
    table td:before {
        content: attr(data-label) ": ";
        font-weight: bold;
        color: #333;
        display: block;
        margin-bottom: 5px;
    }
    
    table input[type="text"] {
        width: 100% !important;
        margin: 0 !important;
        height: 42px !important;
        font-size: 16px !important;
    }
}

/* Common table header styling */
table th {
    background-color: #f8f9fa;
    font-weight: bold;
    color: #333;
    text-align: center;
}

table td {
    text-align: left;
}


/* ZEBRA STRIPING */
table tr:nth-child(even) {
    background-color: #f9f9f9;
}

/* PAGINATION - Desktop 12px */
@media screen and (min-width: 769px) {
    .selected_page,
    input[type="submit"][class*="selected"] {
        padding: 2px 6px !important;
        font-size: 11px !important;
        height: auto !important;
        line-height: 1.2 !important;
        margin: 2px !important;
        background-color: #007bff !important;
        color: white !important;
        border: 1px solid #007bff !important;
        border-radius: 4px !important;
    }

    form[style*="display: inline-block"] input[type="submit"] {
        padding: 2px 6px !important;
        font-size: 11px !important;
        height: auto !important;
        margin: 2px !important;
        border: 1px solid #ddd !important;
        background: white !important;
        border-radius: 4px !important;
        cursor: pointer;
    }

    form[style*="display: inline-block"] input[type="submit"]:hover {
        background-color: #f8f9fa !important;
    }
}

/* Mobile pagination - keep larger */
@media screen and (max-width: 768px) {
    .selected_page,
    input[type="submit"][class*="selected"] {
        padding: 8px 12px !important;
        font-size: 14px !important;
        height: auto !important;
        margin: 4px !important;
    }

    form[style*="display: inline-block"] input[type="submit"] {
        padding: 8px 12px !important;
        font-size: 14px !important;
        height: auto !important;
        margin: 4px !important;
    }
}

/* ====================================================================
   RESPONSIVE FORM LAYOUTS
   ====================================================================*/

/* Form rows */
.form-row {
    display: flex;
    flex-direction: column;
    margin-bottom: 20px;
    gap: 3px;
    width: 100%;
}

.form-row label {
    font-weight: bold;
    color: #333;
    margin-bottom: 2px;
    font-size: 1rem;
}

/* Form row content container */
.form-row-content {
    display: flex;
    gap: 15px;
    width: 100%;
}

.textarea-container {
    flex: 1;
    min-width: 0;
    overflow-x: auto;
}

/* Button column: 2-column grid — AI Assist (col 1) | Preview (col 2) in row 1,
   refine input spanning both columns in row 2 */
.button-column {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto;
    gap: 4px 10px;
    margin-top: 10px;
    width: 100%;
}

.button-column .ai-quick:not(.preview) {
    grid-column: 1;
    grid-row: 1;
    width: 100%;
}

.button-column .ai-quick.preview {
    grid-column: 2;
    grid-row: 1;
    width: auto !important;
}

.button-column .ai-refinement-field {
    grid-column: 1 / -1;
    grid-row: 2;
    width: 100%;
}

.button-column .ai-loading {
    grid-column: 1 / -1;
    grid-row: 3;
}

.ai-quick,
.ai-advanced {
    width: 100%;
    padding: 10px 14px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.3s ease;
}

.ai-quick {
    background: #28a745;
    color: white;
}

.ai-quick:hover {
    background: #218838;
    transform: translateY(-1px);
}

.ai-advanced {
    background: #007cba;
    color: white;
}

.ai-advanced:hover {
    background: #0056b3;
    transform: translateY(-1px);
}

.ai-refinement-field {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 13px;
    background: #f9f9fa;
    color: #666;
    box-sizing: border-box;
    height: 34px;
}

.ai-refinement-field:focus {
    border-color: #007cba;
    background: white;
    color: #333;
    outline: none;
}

.ai-refinement-field::placeholder {
    color: #999;
    font-style: italic;
}

/* ====================================================================
   DESKTOP SPECIFIC STYLES (769px and above)
   ====================================================================*/
@media screen and (min-width: 769px) {
    /* Desktop: AI buttons side by side with textarea */
    .form-row-content {
        flex-direction: row;
        align-items: flex-start;
    }

    .textarea-container {
        flex: 1;
    }

    .button-column {
        flex-shrink: 0;
        width: 340px;
        margin-top: 0;
        align-self: flex-start;
    }
    
    .ai-quick,
    .ai-advanced {
        padding: 8px 12px;
        font-size: 13px;
    }
    
    .ai-refinement-field {
        font-size: 12px;
        height: 30px;
        padding: 6px 8px;
    }
    
    /* Maintenance form specific adjustments */
    div[style*="margin-bottom: 10px"],
    div[style*="display: flex"][style*="align-items: center"] {
        max-width: 500px;
    }
    
    /* Override inline styles for better desktop appearance */
    input[type="text"][style*="width: 200px"] {
        width: 180px !important;
        height: 32px !important;
    }
    
    select[style*="width: 200px"] {
        width: 180px !important;
        height: 32px !important;
    }
    
    input[type="number"][style*="width: 50px"] {
        width: 60px !important;
        height: 32px !important;
    }
    
    textarea[style*="width: 220px"] {
        width: 300px !important;
        min-height: 70px !important;
    }
    
    .box[style*="width: 500px"] {
        width: 520px !important;
    }
}

/* ====================================================================
   MOBILE SPECIFIC STYLES (768px and below)
   ====================================================================*/
@media screen and (max-width: 768px) {
    body {
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        background-attachment: scroll;
    }
    
    body::before {
        display: none;
    }


    .login-wrapper {
        align-items: flex-start;
        padding-top: 10px;
    }

    .login-container,
    .box,
    .boxFullWidth {
        padding: 1.5rem 1.25rem;
        margin: 0;
        max-width: none;
        border-radius: 15px;
        width: 100% !important;
    }
    
    /* Mobile form layout */
    .form-row-content {
        flex-direction: column;
        gap: 15px;
    }
    
    .button-column {
        width: 100%;
        margin-top: 15px;
    }
    
    .ai-quick,
    .ai-advanced {
        padding: 12px 16px;
        font-size: 16px;
    }
    
    .ai-refinement-field {
        height: 42px;
        font-size: 16px;
        padding: 10px 12px;
    }
    
    /* Stack maintenance form elements vertically */
    div[style*="margin-bottom: 10px"],
    div[style*="display: flex"][style*="align-items: center"] {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 5px;
    }
    
    div[style*="margin-bottom: 10px"] label,
    div[style*="display: flex"][style*="align-items: center"] label {
        width: 100% !important;
        min-width: auto !important;
        margin-bottom: 5px;
        text-align: left;
    }
}

/* ====================================================================
   ERROR MESSAGES AND ALERTS
   ====================================================================*/
.error-message {
    background: linear-gradient(135deg, #f8d7da, #f5c6cb);
    color: #721c24;
    padding: 0.75rem 1rem;
    border-radius: 10px;
    margin-bottom: 1.5rem;
    border: 1px solid #f5c6cb;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
}

.error-message i {
    margin-right: 0.5rem;
}

.ai-message {
    position: fixed;
    top: 20px;
    right: 20px;
    left: 20px;
    padding: 15px;
    border-radius: 8px;
    color: white;
    font-weight: bold;
    z-index: 1000;
    text-align: center;
    animation: slideIn 0.3s ease-out;
}

.ai-message.success {
    background: #28a745;
}

.ai-message.error {
    background: #dc3545;
}

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

/* ====================================================================
   ACCESSIBILITY AND FOCUS STYLES
   ====================================================================*/
button:focus,
input:focus,
textarea:focus,
select:focus {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Focus states for table buttons */
table .rounded:focus {
    outline: 1px solid #007cba !important;
    outline-offset: 1px !important;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .box,
    .boxFullWidth {
        border-color: #000;
        border-width: 3px;
    }
    
    input, textarea, select {
        border-width: 3px;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ====================================================================
   UTILITY CLASSES
   ====================================================================*/
.tooltip {
    position: relative;
    display: inline-block;
}

.tooltip .tooltiptext {
    visibility: hidden;
    width: 300px;
    background-color: #555;
    color: #fff;
    text-align: center;
    border-radius: 6px;
    padding: 5px;
    position: absolute;
    z-index: 1;
    bottom: 125%;
    left: 50%;
    margin-left: -150px;
    opacity: 0;
    transition: opacity 0.3s;
}

.tooltip:hover .tooltiptext {
    visibility: visible;
    opacity: 1;
}

/* Loading states */
.ai-loading {
    display: none;
    color: #007cba;
    font-style: italic;
    font-size: 12px;
    text-align: center;
    padding: 8px;
}

/* Button groups */
.button-group {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 20px;
    justify-content: flex-start;
}

@media screen and (max-width: 768px) {
    .button-group {
        flex-direction: column;
    }
    
    .button-group .rounded {
        width: 100%;
        margin: 5px 0;
    }
}

/* ====================================================================
   PRINT STYLES
   ====================================================================*/
@media print {
    body {
        background: white;
        padding: 0;
    }

    .box,
    .boxFullWidth {
        border: 1px solid #000;
        background: white;
        break-inside: avoid;
    }

    .rounded,
    .button-column,
    .password-toggle,
    .password-toggle-btn {
        display: none;
    }

    .ai-message {
        display: none;
    }
}

/* ====================================================================
   CAMPAIGN FORM SPECIFIC STYLES
   ====================================================================*/

/* Instructions box styling */
.instructions-box {
    background-color: #d4edda;
    border: 1px solid #c3e6cb;
    border-radius: 15px;
    padding: 0px 10px;
    margin-bottom: 8px;
}

.instructions-toggle {
    cursor: pointer;
    user-select: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
}


/* Ensure proper viewport handling */
@media screen and (max-width: 768px) {
    /* Fix for some mobile browsers */
    body {
        min-height: 100vh;
        min-height: -webkit-fill-available;
    }
}

/* ====================================================================
   COMPACT TABLE STYLING FOR LEADS AND CAMPAIGNS TABLES
   ====================================================================*/

/* Compact table styling for both leads and campaigns tables */
.leads-table,
.campaigns-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 20px;
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

/* Compact row height - applies to both table types */
.leads-table th,
.leads-table td,
.campaigns-table th,
.campaigns-table td {
    padding: 4px 8px !important;  /* Reduced from 8px 10px */
    text-align: left;
    border-bottom: 1px solid #e9ecef;
    line-height: 1.2 !important;
}

/* Header styling for both table types */
.leads-table th,
.campaigns-table th {
    background-color: #f8f9fa;
    font-weight: bold;
    color: #333;
    border-bottom: 2px solid #dee2e6;
}

/* Hover effects for both table types */
.leads-table tr:hover,
.campaigns-table tr:hover {
    background-color: #f8f9fa;
}

/* Compact buttons for both table types */
.leads-table button,
.leads-table input[type="button"],
.campaigns-table button,
.campaigns-table input[type="button"] {
    padding: 2px 8px !important;  /* Reduced padding */
    font-size: 12px !important;   /* Slightly smaller font */
    min-height: 24px !important;  /* Reduced height */
    line-height: 1.2 !important;
    border-radius: 4px;
    margin: 1px 2px;
}

/* Table input styling for both types */
.leads-table input[type="text"],
.leads-table select,
.campaigns-table input[type="text"],
.campaigns-table select {
    width: 100% !important;
    border: none !important;
    background: transparent !important;
    padding: 4px 6px !important;
    height: 26px !important;
    font-size: 13px;
}

.leads-table input[type="text"]:focus,
.leads-table select:focus,
.campaigns-table input[type="text"]:focus,
.campaigns-table select:focus {
    background: white !important;
    border: 1px solid #007cba !important;
    border-radius: 4px !important;
}

/* Sortable Table Headers */
.sortable-header {
    cursor: pointer;
    user-select: none;
    position: relative;
    padding-right: 20px !important;
    background-color: #f9f9f9;
    border: 1px solid #ddd;
    transition: background-color 0.2s ease;
}

.sortable-header:hover {
    background-color: #e9e9e9;
    border-color: #007bff;
}

/* Add a subtle sort icon to ALL sortable headers */
.sortable-header::before {
    content: "⇅";
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 10px;
    color: #ccc;
    opacity: 0.6;
}

.sortable-header:hover::before {
    color: #007bff;
    opacity: 1;
}

.sort-arrow {
    position: absolute;
    right: 5px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 12px;
    color: #007bff;
    font-weight: bold;
}

.sort-arrow.asc::after {
    content: "▲";
}

.sort-arrow.desc::after {
    content: "▼";
}

/* Hide the generic sort icon when showing actual arrow */
.sortable-header:has(.sort-arrow)::before {
    display: none;
}

/* Sort indicator for leads table headers */
.leads-table th[data-sort] { cursor: pointer; user-select: none; }
.leads-table th[data-sort]:hover { background-color: #e9ecef; }
.sort-ind { font-size: 0.8em; opacity: 0.5; }

/* Mobile responsive table styling for both types */
@media screen and (max-width: 768px) {
    .leads-table,
    .campaigns-table {
        font-size: 14px;
    }
    
    .leads-table,
    .leads-table thead,
    .leads-table tbody,
    .leads-table th,
    .leads-table td,
    .leads-table tr,
    .campaigns-table,
    .campaigns-table thead,
    .campaigns-table tbody,
    .campaigns-table th,
    .campaigns-table td,
    .campaigns-table tr {
        display: block;
    }
    
    .leads-table thead tr,
    .campaigns-table thead tr {
        position: absolute;
        top: -9999px;
        left: -9999px;
    }
    
    .leads-table tr,
    .campaigns-table tr {
        border: 1px solid #ccc;
        margin-bottom: 10px;
        padding: 10px;
        border-radius: 8px;
        background: white;
    }
    
    .leads-table td,
    .campaigns-table td {
        border: none;
        position: relative;
padding: 12px 0 12px 45% !important;
width: 42%;
    }

    .leads-table td:before,
    .campaigns-table td:before {
        content: attr(data-label) ": " !important;
        position: absolute !important;
        left: 6px;
        width: 42% !important;
        padding-right: 10px;
        white-space: nowrap;
        font-weight: bold;
        color: #333;
    }
}

/* Instructions section mobile styling */
@media screen and (max-width: 768px) {
    .instructions-box {
        padding: 15px;
        margin-bottom: 15px;
    }
    
    .instructions-toggle {
        font-size: 14px;
    }
}

/* Form inputs mobile optimization */
@media screen and (max-width: 768px) {
    .form-control,
    input[type="text"],
    input[type="email"],
    select {
        font-size: 16px; /* Prevents zoom on iOS */
        height: 44px;
        padding: 0.75rem 1rem;
    }
    
    textarea {
        font-size: 16px;
        min-height: 100px;
    }
}

/* ====================================================================
   CAMPAIGN DEFINITION TABLE MOBILE RESPONSIVE CSS
   ====================================================================*/
/* Campaign Definition Table Base Styling */
.campaignDef-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 8px;
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.campaignDef-table th,
.campaignDef-table td {
    padding: 4px 10px;
    text-align: left;
    border-bottom: 1px solid #e9ecef;
}

.campaignDef-table th {
    background-color: #f8f9fa;
    font-weight: bold;
    color: #333;
    border-bottom: 2px solid #dee2e6;
}

/* Desktop styling for campaignDef-table */
@media screen and (min-width: 769px) {
    .campaignDef-table th,
    .campaignDef-table td {
        padding: 8px 10px;
        font-size: 14px;
    }
    
    .campaignDef-table input[type="text"] {
        width: 100%;
        padding: 4px 6px;
        font-size: 14px;
        border: 1px solid #ccc;
        border-radius: 4px;
        height: 28px;
    }
    
    .campaignDef-table input[type="checkbox"] {
        width: 18px;
        height: 18px;
    }
}

/* Mobile responsive styling for campaignDef-table */
@media screen and (max-width: 768px) {
    .campaignDef-table {
        font-size: 14px;
    }
    
    .campaignDef-table,
    .campaignDef-table thead,
    .campaignDef-table tbody,
    .campaignDef-table th,
    .campaignDef-table td,
    .campaignDef-table tr {
        display: block;
    }
    
    .campaignDef-table thead tr {
        position: absolute;
        top: -9999px;
        left: -9999px;
    }
    
    .campaignDef-table tr {
        border: 1px solid #ccc;
        margin-bottom: 10px;
        padding: 10px;
        border-radius: 8px;
        background: white;
    }
    
    .campaignDef-table td {
        border: none;
        position: relative;
    padding: 12px 0 12px 45% !important;
        text-align: left;
    }
    
    .campaignDef-table td:before {
        content: attr(data-label) ": " !important;
        position: absolute !important;
        left: 6px;
    width: 42% !important; 
        padding-right: 10px;
        white-space: nowrap;
        font-weight: bold;
        color: #333;
    }
    
    /* Style inputs within campaign table on mobile */
    .campaignDef-table input[type="text"] {
        width: 100% !important;
        font-size: 16px !important;
        height: 44px !important;
        padding: 0.75rem 1rem !important;
        border: 1px solid #ccc !important;
        border-radius: 4px !important;
        margin: 0 !important;
    }
    
    .campaignDef-table input[type="checkbox"] {
        transform: scale(1.5);
        margin: 0 auto !important;
        display: block !important;
    }
}


/* Preview button - exact same height as AI Assist button */
.ai-quick.preview {
    background: #6c757d !important;  /* Gray background instead of green */
    width: auto !important;          /* Override the 100% width from .ai-quick */
    min-width: 100px;               /* Set a reasonable minimum width */
    flex-shrink: 0;                 /* Don't shrink in flex containers */
    
    /* Force exact same dimensions as .ai-quick */
    padding: 10px 14px !important;  /* Match mobile padding exactly */
    height: auto !important;        /* Let height be determined by padding */
    box-sizing: border-box !important;
    font-size: 14px !important;     /* Match font size exactly */
    font-weight: 600 !important;    /* Match font weight exactly */
    line-height: normal !important; /* Ensure same line height */
}

.ai-quick.preview:hover {
    background: #5a6268 !important; /* Darker gray on hover */
    transform: translateY(-1px);    /* Keep the same hover animation */
}

/* Desktop: Match desktop AI Assist button exactly */
@media screen and (min-width: 769px) {
    .ai-quick.preview {
        padding: 8px 12px !important;  /* Match desktop padding exactly */
        font-size: 13px !important;    /* Match desktop font size exactly */
    }
}

.btn-delete {
    background-color: #dc3545 !important;
    color: white !important;
}

.btn-delete:hover {
    background-color: #c82333 !important;
    color: white !important;
}

.btn-archive {
    background-color: #fd7e14 !important;
    color: white !important;
}

.btn-archive:hover {
    background-color: #e8650a !important;
    color: white !important;
}

.btn-restore {
    background-color: #28a745 !important;
    color: white !important;
}

.btn-restore:hover {
    background-color: #218838 !important;
    color: white !important;
}

.btn-print {
    background-color: #28a745 !important;
    color: white !important;
}

.btn-print:hover {
    background-color: #218838 !important;
}

/* ── Edit Lead ── */
.lead-form-group {
    margin-bottom: 10px;
    display: flex;
    align-items: center;
}
.lead-form-group .label {
    width: 100px;
    padding-left: 30px;
    flex-shrink: 0;
}
.lead-form-group .textfield {
    width: 200px;
}
.lead-form-group .checkbox {
    width: 195px;
}
.lead-form-group .notes {
    width: calc(100% - 100px);
}
.auto-expanding {
    overflow: hidden;
    width: calc(100% - 100px);
    resize: none;
    min-height: 50px;
    box-sizing: border-box;
}

/* ── Campaign Defs ── */
.alert {
    padding: 15px;
    margin-bottom: 20px;
    border: 1px solid transparent;
    border-radius: 4px;
    animation: fadeIn 0.5s ease-in;
}
.alert-success { color: #3c763d; background-color: #dff0d8; border-color: #d6e9c6; }
.alert-warning  { color: #8a6d3b; background-color: #fcf8e3; border-color: #faebcc; }
.alert-danger   { color: #a94442; background-color: #f2dede; border-color: #ebccd1; }
.alert-info     { color: #31708f; background-color: #d9edf7; border-color: #bce8f1; }

.newbie-setup {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 30px;
    border-radius: 10px;
    margin: 20px 0;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}
.setup-form {
    background: rgba(255,255,255,0.1);
    padding: 25px;
    border-radius: 8px;
    backdrop-filter: blur(10px);
}
.btn-create {
    background: #28a745;
    color: white;
    padding: 15px 30px;
    border: none;
    border-radius: 6px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
}
.btn-create:hover {
    background: #218838;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
}
.newbie-setup .instructions {
    background: rgba(255,255,255,0.1);
    padding: 15px;
    border-radius: 6px;
    margin-bottom: 20px;
    font-size: 14px;
    line-height: 1.6;
}
#progress-banner { animation: slideIn 0.5s ease-out; }
.fa-spin { animation: fa-spin 2s infinite linear; }
@keyframes fa-spin {
    0%   { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Campaign Defs table (show_campaignDefs.php list view) */
.campaigns-table th {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 15px;
    text-align: left;
    font-weight: bold;
}
.campaigns-table td {
    padding: 12px 15px;
    border-bottom: 1px solid #eee;
}
.campaigns-table tr:hover { background-color: #f8f9fa; }

.btn-action {
    padding: 6px 12px;
    margin: 2px;
    border: none;
    border-radius: 4px;
    text-decoration: none;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
}
.btn-edit            { background-color: #007bff; color: white; }
.btn-edit:hover      { background-color: #0056b3; color: white; }
.btn-duplicate       { background-color: #6c757d; color: white; }
.btn-duplicate:hover { background-color: #545b62; color: white; }
.campaign-purpose    { max-width: 300px; word-wrap: break-word; }

/* Notes / Background tab toggle on edit_lead form */
.notes-tab-nav { display: flex; gap: 0; margin-bottom: 0; border-bottom: 2px solid #007bff; flex-wrap: nowrap; align-items: flex-end; }
.notes-tab-btn {
    padding: 5px 20px !important;
    border: 1px solid #ccc !important;
    border-bottom: none !important;
    background: #f0f0f0 !important;
    color: #555 !important;
    border-radius: 6px 6px 0 0 !important;
    cursor: pointer !important;
    font-size: 14px !important;
    font-weight: normal !important;
    min-height: unset !important;
    min-width: unset !important;
    margin-bottom: 0 !important;
    margin-right: 3px !important;
    line-height: 1.4 !important;
}
.notes-tab-btn.active {
    background: #007bff !important;
    color: white !important;
    border-color: #007bff !important;
    font-weight: bold !important;
}
.notes-tab-content { display: none; width: 100%; }
.notes-tab-content.active { display: flex; width: 100%; }
.notes-tab-content textarea { width: 100%; box-sizing: border-box; min-height: 80px; }
.notes-action-btn {
    padding: 4px 10px !important;
    font-size: 0.82rem !important;
    font-weight: normal !important;
    border: 1px solid #999 !important;
    border-radius: 4px !important;
    background: #f0f0f0 !important;
    color: #333 !important;
    cursor: pointer !important;
    min-height: unset !important;
    min-width: unset !important;
    margin: 0 !important;
    line-height: 1.4 !important;
    white-space: nowrap !important;
    box-shadow: 0 1px 2px rgba(0,0,0,0.15) !important;
}
.notes-action-btn:hover { background: #e0e8ff !important; border-color: #007bff !important; color: #007bff !important; }
.msg-drop-zone {
    padding: 3px 8px;
    font-size: 0.8rem;
    color: #888;
    border: 2px dashed #aaa;
    border-radius: 4px;
    cursor: default;
    white-space: nowrap;
    display: flex;
    align-items: center;
    transition: all 0.15s;
}
.msg-drop-zone.drag-over {
    border-color: #007bff;
    color: #007bff;
    background: #e8f0ff;
}

/* ====================================================================
   MAINTENANCE PAGE STYLES
   ====================================================================*/

/* Show all passwords container */
.show-all-container {
    margin: 15px 0;
    display: flex;
    align-items: center;
}

.show-all-container label {
    margin-left: 8px;
    color: #333;
    cursor: pointer;
    font-weight: normal;
}

/* Password field container styling */
.password-field-container {
    position: relative;
    margin-bottom: 15px !important;
    width: 100%;
    max-width: 280px;
}

.password-field-container label {
    display: block;
    margin-bottom: 5px;
    color: #333;
    font-weight: bold;
    width: auto;
    min-width: auto;
}

.password-field-container input[type="password"],
.password-field-container input[type="text"] {
    width: 100% !important;
    padding: 6px 30px 6px 10px !important;
    height: 32px !important;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 14px;
    box-sizing: border-box;
}

@media screen and (min-width: 769px) {
    .password-field-container {
        max-width: 260px;
    }
}

@media screen and (max-width: 768px) {
    .password-field-container {
        width: 100%;
        max-width: none;
    }

    .password-field-container input {
        width: 100% !important;
        height: 38px !important;
    }
}

/* ====================================================================
   SETTINGS TAB STYLES
   ====================================================================*/
.settings-tab-nav { display: flex; gap: 4px; margin-bottom: 0; border-bottom: 2px solid #007bff; }
.settings-tab-btn { padding: 6px 16px; border: 1px solid #007bff; border-bottom: none; background: white; color: #007bff; border-radius: 4px 4px 0 0; cursor: pointer; font-size: 14px; }
.settings-tab-btn.active { background: #007bff; color: white; }
.settings-tab-content { display: none; }
.settings-tab-content.active { display: block; }
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 24px; align-items: center; padding: 8px 0; }
.settings-field { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.settings-field label { font-weight: bold; margin: 0; flex-shrink: 0; }
.settings-field input[type="text"], .settings-field input[type="number"], .settings-field select { flex: 1; min-width: 160px; padding: 3px 6px; border: 1px solid #ccc; border-radius: 3px; }
.settings-field textarea { flex: 1; padding: 3px 6px; border: 1px solid #ccc; border-radius: 3px; box-sizing: border-box; white-space: normal; }
.field-full { grid-column: 1 / -1; }

/* ====================================================================
   CAMPAIGN DEFINITION EDITOR STYLES
   ====================================================================*/

/* Spinner animation for loading indicator */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* AI Build All button */
.ai-build-all-btn:hover {
    background: #45a049 !important;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.4) !important;
}

.ai-build-all-btn:active {
    transform: translateY(0px);
}

.ai-build-all-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

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

.ai-build-all-container {
    animation: fadeInUp 0.6s ease-out;
}

@media (max-width: 768px) {
    .ai-build-all-container {
        padding: 15px;
        margin: 15px 0;
    }

    .ai-build-all-btn {
        padding: 12px 25px;
        font-size: 1.1em;
    }
}

/* Preview button */
.preview-btn {
    background-color: #6c757d;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    margin-top: 5px;
    margin-left: 5px;
    transition: background-color 0.3s;
}

.preview-btn:hover {
    background-color: #545b62;
}

/* Preview modal */
.preview-modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
}

.preview-content {
    background-color: #fefefe;
    margin: 5% auto;
    padding: 20px;
    border: 1px solid #888;
    width: 80%;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
    border-radius: 8px;
    position: relative;
}

.preview-close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    position: absolute;
    top: 10px;
    right: 20px;
    cursor: pointer;
}

.preview-close:hover {
    color: black;
}

.preview-email-header {
    background-color: #f8f9fa;
    padding: 10px;
    border-radius: 4px;
    margin-bottom: 15px;
    border: 1px solid #dee2e6;
}

.preview-email-body {
    background-color: white;
    padding: 15px;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    white-space: pre-wrap;
    font-family: Arial, sans-serif;
    line-height: 1.5;
}

/* Collapsible Section Styles — these override .boxFullWidth base styles */
.boxFullWidth h3 {
    background-color: #f8f9fa;
    margin: 0;
    padding: 6px 15px;
    cursor: pointer;
    user-select: none;
    display: flex;
    justify-content: flex-start;
    align-items: center;
    font-weight: 600;
    border-bottom: 1px solid #ddd;
    transition: background-color 0.2s ease;
    position: relative;
    width: 100%;
}

.boxFullWidth h3:hover {
    background-color: #e9ecef;
}

.boxFullWidth h3.active {
    background-color: #007bff;
    color: white;
}

.boxFullWidth h3::after {
    content: "▼";
    font-size: 14px;
    transition: transform 0.2s ease;
    margin-left: auto;
}

.boxFullWidth h3.active::after {
    transform: rotate(180deg);
}

.boxFullWidth .section-content {
    padding: 8px 15px;
    display: none;
    background-color: white;
}

.boxFullWidth.active .section-content {
    display: block;
}

.boxFullWidth h3 .section-icon {
    margin-right: 8px;
}

.boxFullWidth h3 input[type="checkbox"] {
    flex-shrink: 0;
    margin-right: 10px;
    cursor: pointer;
}

.boxFullWidth h3 input[type="checkbox"]:hover {
    opacity: 0.8;
}

.boxFullWidth:not(.active) {
    margin-bottom: 3px;
}

/* Collapsible controls */
.collapsible-controls {
    display: inline-block;
    margin-right: auto;
}

.collapsible-controls button {
    background: #6c757d;
    color: white;
    border: none;
    padding: 8px 15px;
    border-radius: 4px;
    cursor: pointer;
    margin-right: 10px;
    font-size: 12px;
}

.collapsible-controls button:hover {
    background: #5a6268;
}

.collapsible-controls button.expand {
    background: #007bff;
}

.collapsible-controls button.expand:hover {
    background: #0056b3;
}

/* Button row */
.button-row {
    margin: 15px 0 !important;
    border: none !important;
    background: none !important;
    background-color: transparent !important;
    padding: 0 !important;
    box-shadow: none !important;
    outline: none !important;
    border-radius: 0 !important;
}

.button-row,
.button-row * {
    border: none !important;
    background: none !important;
    background-color: transparent !important;
    box-shadow: none !important;
}

.button-row {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 10px !important;
    justify-content: space-between !important;
    align-items: center !important;
}
