/* Common CSS fixes for all SalesCRM pages */

/* Fix header size - it's currently too large */
header.main-header {
    height: auto;
    min-height: 60px;
}

header.main-header .navbar {
    padding-top: 0.25rem;
    padding-bottom: 0.25rem;
}

header.main-header .navbar-brand {
    font-size: 1.1rem;
    padding: 0;
}

header.main-header .navbar-brand img {
    height: 32px !important;
    width: auto;
}



/* Improve scrolling behavior for pre elements */
pre {
    max-height: 300px;
    overflow-y: auto;
    overflow-x: auto;
    white-space: pre-wrap;
    word-wrap: break-word;
    background-color: #f8f9fc;
    padding: 1rem;
    border-radius: 4px;
    border: 1px solid rgba(0, 0, 0, 0.125);
}

/* Ensure footer stays at bottom and make it more compact */
html, body {
    height: 100%;
    margin: 0;
}

body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

main.container, main.container-fluid {
    flex: 1 0 auto;
}

footer {
    flex-shrink: 0;
    padding-top: 1rem !important;
    padding-bottom: 1rem !important;
}

footer img {
    height: 35px !important;
    width: auto;
}

footer h5 {
    font-size: 1rem;
    margin-bottom: 0.25rem !important;
}

/* Responsive tables */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Form improvements */
textarea {
    min-height: 120px;
}

/* Fix long content in cards */
.card {
    overflow: hidden;
}

.card-body {
    overflow-wrap: break-word;
}

/* Mobile optimizations */
@media (max-width: 768px) {
    .container-fluid {
        padding-bottom: 100px;
    }
    
    /* Fix small screen header */
    header.main-header .navbar-brand {
        font-size: 0.9rem;
    }
    
    /* Better table scrolling on mobile */
    .table-responsive {
        margin-bottom: 1rem;
    }
    
    /* More compact forms on mobile */
    .card-body {
        padding: 1rem;
    }
}

/* Fix JSON input rendering */
.json-editor {
    font-family: monospace;
    direction: ltr !important;
    text-align: left !important;
}

/* Fix code blocks in markdown */
code {
    background-color: #f0f0f0;
    padding: 2px 4px;
    border-radius: 3px;
    color: #333;
    font-size: 0.9em;
}

/* Fix card header spacing */
.card-header {
    padding: 0.75rem 1.25rem;
}

/* Specific fixes for workflow rules content */
.workflow-container pre code {
    max-height: 350px;
    overflow-y: auto;
}

/* Fix for JSON fields in workflow forms */
.workflow-container .json-editor {
    font-size: 14px;
    line-height: 1.4;
    max-height: 400px;
}

/* Prevent workflow form content overflow */
.workflow-form-section {
    margin-bottom: 2rem;
    overflow-x: hidden;
}

/* Fix modal overflow issues */
.modal-body {
    max-height: 70vh;
    overflow-y: auto;
}

/* Make all form elements responsive */
input, select, textarea {
    max-width: 100%;
}

/* Fix rendering issues for general tables */
table {
    table-layout: auto;
    width: 100%;
}

/* Fix for lengthy text in tables */
td {
    word-break: break-word;
    max-width: 300px;
}

/* RTL specific fixes */
[dir="rtl"] .ml-auto {
    margin-right: auto !important;
    margin-left: 0 !important;
}

[dir="rtl"] .mr-auto {
    margin-left: auto !important;
    margin-right: 0 !important;
}

/* Mobile optimizations */
@media (max-width: 768px) {
    .container-fluid {
        padding-bottom: 100px;
    }
    
    /* Fix small screen header */
    header.main-header .navbar-brand {
        font-size: 0.9rem;
    }
    
    /* Better table scrolling on mobile */
    .table-responsive {
        margin-bottom: 1rem;
    }
    
    /* More compact forms on mobile */
    .card-body {
        padding: 1rem;
    }
    
    pre {
        max-height: 200px;
    }
}
