/* style.css - Minimalist & Modern Design System */

* {
    box-sizing: border-box;
}


:root {
    --bg-color: #f8fafc;
    /* Very light slate */
    --surface: #ffffff;
    --text-primary: #111827;
    /* Dark gray/almost black */
    --text-secondary: #4b5563;
    /* Medium gray */
    --text-muted: #9ca3af;
    /* Light gray */

    --border-color: #e5e7eb;
    --border-radius: 8px;
    --border-radius-sm: 4px;

    --primary: #0f172a;
    /* Slate 900 - sleek black/dark blue */
    --primary-hover: #1e293b;
    --primary-text: #ffffff;

    --accent: #2563eb;
    /* Blue for links/highlights if needed */
    --danger: #ef4444;
    /* Clean red */
    --danger-bg: #fef2f2;
    --danger-border: #fecaca;

    --success: #10b981;
    --success-bg: #ecfdf5;

    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);

    --container-width: 1200px;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    margin: 0;
    padding: 0;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    animation: fadeIn 0.4s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(12px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Typography */
h1,
h2,
h3,
h4,
h5,
h6 {
    margin-top: 0;
    font-weight: 600;
    color: #000000;
}

p {
    color: var(--text-secondary);
}

/* Header */
.header {
    background-color: var(--surface);
    border-bottom: 1px solid var(--border-color);
    z-index: 1000;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

.header-inner {
    max-width: var(--container-width);
    margin: 0 auto;
    min-height: 80px;
    height: auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 24px;
}

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

.header-left .logo {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: var(--text-primary);
    font-weight: 800;
    font-size: 20px;
    letter-spacing: -0.025em;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 24px;
}

.header-user {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    border-radius: var(--border-radius);
    background: #f9fafb;
    border: 1px solid var(--border-color);
}

.header-user span {
    font-size: 14px;
    color: var(--text-secondary);
}

.header-lang {
    display: flex;
    gap: 8px;
    font-size: 13px;
    font-weight: 500;
    margin-left: 20px;
    padding-left: 20px;
    border-left: 1px solid var(--border-color);
}

.user-details {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    line-height: 1.2;
}

.logout-header-btn {
    color: #000000 !important;
    border-color: #000000 !important;
    background: #ffffff !important;
    font-weight: 600 !important;
}

.header-lang a {
    color: var(--text-muted);
    text-decoration: none;
    transition: color 0.2s;
}

.header-lang a.active {
    color: var(--primary);
    font-weight: 700;
}

/* Breadcrumbs */
.breadcrumb-bar {
    background: #f8fafc;
    padding: 12px 0;
    margin-top: 0;
}

.breadcrumb-inner {
    max-width: var(--container-width);
    margin: 0 auto;
    padding: 0 24px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 16px;
    color: var(--text-muted);
}

.breadcrumb-inner a {
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 0.2s;
}

.breadcrumb-inner a:hover {
    color: var(--primary);
}

.breadcrumb-separator {
    color: var(--border-color);
    font-size: 12px;
}

.breadcrumb-inner span.current {
    color: var(--text-primary);
    font-weight: 500;
    text-decoration: underline;
    text-underline-offset: 4px;
}

/* Page Header */
.page-header {
    background: linear-gradient(to bottom, #ffffff, var(--bg-color));
    padding: 20px 0 0 0;
    animation: slideUp 0.5s ease-out;
}

.page-header-inner {
    max-width: var(--container-width);
    margin: 0 auto;
    padding: 0 24px 24px 24px;
    position: relative;
}

.page-header-inner::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 24px;
    right: 24px;
    height: 2px;
    background-color: var(--border-color);
}

.page-header h1 {
    font-size: 36px;
    margin-bottom: 12px;
    font-weight: 800;
    letter-spacing: -0.03em;
    color: var(--primary);
}

.page-header p {
    color: var(--text-secondary);
    margin: 0;
    font-size: 16px;
    max-width: 800px;
    line-height: 1.6;
}

.header-lang a:hover {
    color: var(--accent);
}

/* Container */
.container {
    max-width: var(--container-width);
    margin: 40px auto;
    padding: 0 24px;
    animation: slideUp 0.6s ease-out backwards;
    animation-delay: 0.1s;
}

/* Layout Utilities */
.container-grid {
    max-width: var(--container-width);
    margin: 10px auto;
    padding: 0 24px;
    display: grid;
    gap: 32px;
    align-items: start;
    animation: slideUp 0.6s ease-out backwards;
    animation-delay: 0.1s;
}

.grid-2-1 {
    grid-template-columns: 2fr 1fr;
}

.grid-1-1 {
    grid-template-columns: 1fr 1fr;
}

.grid-sidebar {
    grid-template-columns: 340px 1fr;
    gap: 24px;
}

@media (max-width: 1024px) {
    .container-grid {
        grid-template-columns: 1fr;
    }
}

.flex-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 24px;
    margin-bottom: 32px;
}

.flex-group {
    display: flex;
    align-items: center;
    gap: 16px;
}

@media (max-width: 768px) {
    .flex-header {
        flex-direction: column;
        align-items: stretch;
    }

    .flex-group {
        flex-direction: column;
        align-items: stretch;
    }
}


/* Sidebar styling */
.sidebar-sticky-card {
    border: 1px solid var(--border-color);
}

.sidebar-panel {
    background: var(--surface);
    padding: 24px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    position: sticky;
    top: 20px;
}

/* Cards */
.card {
    background: var(--surface);
    padding: 32px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    margin-bottom: 24px;
    transition: box-shadow 0.2s ease;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    border: 1px solid transparent;
    border-radius: var(--border-radius-sm);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s ease;
    box-sizing: border-box;
}

.btn:disabled,
.btn.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background-color: var(--bg-color);
    border-color: var(--border-color);
    color: var(--text-muted);
}

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

.btn-primary:hover {
    background-color: var(--primary-hover);
    box-shadow: var(--shadow-sm);
}

.btn-secondary,
.btn-outline {
    background-color: var(--surface);
    color: var(--text-primary);
    border-color: var(--border-color);
}

.btn-secondary:hover,
.btn-outline:hover {
    background-color: #f9fafb;
    border-color: #d1d5db;
}

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

.btn-danger:hover {
    background-color: #dc2626;
}

.btn-danger-outline {
    background-color: white;
    color: #9ca3af;
    border: 1px solid #9ca3af;
}

.btn-danger-outline:hover {
    background-color: var(--danger);
    color: white;
    border-color: var(--danger);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
}

/* Forms & Inputs */
.form-group {
    margin-bottom: 24px;
}

label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 8px;
    color: var(--text-primary);
}

h1,
h2,
h3 {
    margin-top: 0;
    color: #000000;
}

input[type="text"],
input[type="email"],
input[type="number"],
input[type="date"],
select,
textarea {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    font-size: 15px;
    font-family: inherit;
    color: var(--text-primary);
    background-color: var(--surface);
    box-sizing: border-box;
    transition: border-color 0.2s, box-shadow 0.2s;
    appearance: none;
}

/* Custom Select Arrow */
select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%236b7280'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px;
    padding-right: 40px;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(15, 23, 42, 0.1);
}

textarea {
    resize: vertical;
    min-height: 120px;
    /* Grows with its content; the script in includes/footer_ui.php covers browsers without field-sizing */
    field-sizing: content;
}

.required-star {
    color: var(--danger);
    margin-left: 2px;
}

/* Checkboxes & Radios */
.check-wrapper,
.checkbox-container {
    display: inline-flex;
    align-items: flex-start;
    gap: 10px;
    cursor: pointer;
    font-weight: normal;
}

input[type="checkbox"],
input[type="radio"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--primary);
    margin-top: 2px;
}

/* Tables */
table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: var(--surface);
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
    overflow: hidden;
}

th {
    background: #f9fafb;
    text-align: left;
    padding: 14px 20px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

td {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    font-size: 14px;
    color: var(--text-primary);
}

tr:last-child td {
    border-bottom: none;
}

tr.clickable-row {
    cursor: pointer;
}

tr:hover td {
    background-color: #f9fafb;
}

table.cases-table {
    table-layout: fixed;
}

.case-title-content {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
    width: 100%;
}

/* Badges & Tags */
.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 9999px;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
}

.badge-gray {
    background-color: #f3f4f6;
    color: #4b5563;
}

/* Tag filter pills */
.tag-filter-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.tag-filter-label {
    display: block;
    cursor: pointer;
    margin-right: 0;
    margin-bottom: 0;
}

.tag-filter-label input[type="checkbox"] {
    display: none;
}

.tag-filter-pill {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border-radius: var(--border-radius-sm);
    background-color: #ffffff;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s;
    user-select: none;
}

.tag-filter-label input[type="checkbox"]:checked+.tag-filter-pill {
    background-color: #eff6ff;
    border-color: #bfdbfe;
    color: #2563eb;
}

.tag-filter-label:hover .tag-filter-pill {
    background-color: var(--bg-color);
}

.badge-blue {
    background-color: #eff6ff;
    color: #2563eb;
}

.badge-green {
    background-color: var(--success-bg);
    color: var(--success);
}

.badge-red {
    background-color: var(--danger-bg);
    color: var(--danger);
}

.badge-purple {
    background-color: #f5f3ff;
    color: #7c3aed;
}

.badge-yellow {
    background-color: #fefce8;
    color: #a16207;
}

.badge-pink {
    background-color: #fdf2f8;
    color: #db2777;
}

.badge-indigo {
    background-color: #eef2ff;
    color: #4f46e5;
}

.badge-teal {
    background-color: #f0fdfa;
    color: #0d9488;
}

.badge-orange {
    background-color: #fff7ed;
    color: #ea580c;
}

.badge-cyan {
    background-color: #ecfeff;
    color: #0891b2;
}

.text-blue {
    color: #2563eb;
}

.text-purple {
    color: #7c3aed;
}

.text-green {
    color: #10b981;
}

.text-yellow {
    color: #a16207;
}

.text-pink {
    color: #db2777;
}

.text-indigo {
    color: #4f46e5;
}

.text-teal {
    color: #0d9488;
}

.text-orange {
    color: #ea580c;
}

.text-cyan {
    color: #0891b2;
}

.text-gray {
    color: #64748b;
}

/* Alerts / States */
.alert {
    padding: 16px;
    border-radius: var(--border-radius-sm);
    margin-bottom: 24px;
    font-size: 14px;
}

.alert-danger {
    background-color: var(--danger-bg);
    color: var(--danger);
    border: 1px solid var(--danger-border);
}

.alert-info {
    background-color: #eff6ff;
    color: #1d4ed8;
    border: 1px solid #bfdbfe;
}

.empty-state {
    text-align: center;
    padding: 80px 40px;
    background: #ffffff;
    border-radius: 16px;
    border: 2px dashed var(--border-color);
    color: var(--text-secondary);
    max-width: 600px;
    margin: 40px auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.6s ease-out;
}

.empty-state-icon {
    width: 64px;
    height: 64px;
    background: #f1f5f9;
    color: var(--text-muted);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 24px;
}

.empty-state h2,
.empty-state h3 {
    color: var(--text-primary);
    margin: 0 0 12px 0;
    font-size: 24px;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.empty-state p {
    margin: 0 0 32px 0;
    font-size: 16px;
    line-height: 1.6;
    max-width: 400px;
}

/* Sidebar & Layout Defaults */
.sidebar {
    width: 380px;
    padding: 0 32px 0 0;
}

.main {
    flex-grow: 1;
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 10000;
}

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

.modal {
    background: var(--surface);
    border-radius: var(--border-radius);
    width: 100%;
    max-width: 500px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    border: 1px solid var(--border-color);
    position: relative;
    animation: modal-appear 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modal-appear {
    from {
        opacity: 0;
        transform: translateY(10px) scale(0.98);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

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

.modal-header h2 {
    margin: 0;
    font-size: 20px;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-muted);
    transition: color 0.2s;
    line-height: 1;
}

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

.modal-body {
    padding: 24px;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    background: #f9fafb;
    border-bottom-left-radius: var(--border-radius);
    border-bottom-right-radius: var(--border-radius);
    gap: 12px;
}

/* Toggle Switch */
.switch {
    display: inline-block;
    height: 24px;
    position: relative;
    width: 44px;
}

.switch input {
    display: none;
}

.slider {
    background-color: #cbd5e1;
    bottom: 0;
    cursor: pointer;
    left: 0;
    position: absolute;
    right: 0;
    top: 0;
    transition: .4s;
    border-radius: 24px;
}

.slider:before {
    background-color: #fff;
    bottom: 4px;
    content: "";
    height: 16px;
    left: 4px;
    position: absolute;
    transition: .4s;
    width: 16px;
    border-radius: 50%;
}

input:checked+.slider {
    background-color: var(--success);
}

input:checked+.slider:before {
    transform: translateX(20px);
}

/* Footer Styles */
.footer {
    background-color: transparent;
    padding: 0;
    margin-top: 80px;
    margin-bottom: 0;
}

.footer-inner {
    max-width: var(--container-width);
    margin: 0 auto;
    padding: 60px 24px 80px;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
}

.footer-inner::before {
    content: '';
    position: absolute;
    top: 0;
    left: 24px;
    right: 24px;
    height: 1px;
    background-color: var(--border-color);
}

.footer-left {
    display: flex;
    align-items: center;
    gap: 24px;
}

.footer-logo-img {
    height: 80px;
    width: auto;
    opacity: 0.9;
    transition: opacity 0.3s;
}

.footer-logo-img:hover {
    opacity: 1;
}

.footer-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.footer-info h4 {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
    color: var(--primary);
}

.footer-info p {
    margin: 0;
    font-size: 14px;
    color: var(--text-muted);
}

.footer-links {
    display: flex;
    gap: 32px;
}

.footer-links a {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: color 0.2s;
}

.footer-links a:hover {
    color: var(--primary);
}

.footer-center-content {
    text-align: center;
    color: var(--text-muted);
    font-size: 14px;
    white-space: nowrap;
    line-height: 1.5;
    width: 100%;
}

.manual-link {
    color: inherit;
    text-decoration: underline;
    text-underline-offset: 2px;
    transition: color 0.2s;
    margin-top: 8px;
    display: inline-block;
}

.manual-link:hover {
    color: var(--primary);
}

@media (max-width: 768px) {
    .footer-inner {
        flex-direction: column;
        text-align: center;
        gap: 32px;
        padding-top: 40px;
        padding-bottom: 40px;
    }

    .footer-left {
        flex-direction: column;
        gap: 16px;
    }

    .footer-center-content {
        white-space: normal;
    }
}

.error-tooltip {
    position: absolute;
    background: #1e293b;
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 13px;
    z-index: 1000;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    pointer-events: none;
    animation: fadeIn 0.2s ease-out;
    white-space: nowrap;
}

.error-tooltip::after {
    content: '';
    position: absolute;
    bottom: -6px;
    left: 20px;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-top: 6px solid #1e293b;
}

/* Dropdown Menu */
.dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-content {
    display: none;
    position: absolute;
    right: 0;
    top: 100%;
    background-color: var(--surface);
    min-width: 180px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    z-index: 100;
    margin-top: 8px;
    padding: 8px 0;
    animation: fadeIn 0.2s ease-out;
}

.dropdown-content button {
    width: 100%;
    padding: 10px 16px;
    text-align: left;
    border: none;
    background: none;
    font-size: 14px;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.2s;
}

.dropdown-content button:hover {
    background-color: #f1f5f9;
    color: var(--primary);
}

.dropdown-content button svg {
    color: var(--text-muted);
}

.dropdown-content button:hover svg {
    color: var(--primary);
}

.dropdown.active .dropdown-content {
    display: block;
}

/* --- Responsive Design --- */

@media (max-width: 1200px) {
    :root {
        --container-width: 100%;
    }

    .container,
    .container-grid,
    .header-inner,
    .page-header-inner,
    .breadcrumb-inner,
    .footer-inner {
        padding-left: 16px;
        padding-right: 16px;
    }
}

.mobile-menu-toggle {
    display: none;
    background: none;
    border: none;
    padding: 8px;
    cursor: pointer;
    color: var(--text-primary);
    transition: background 0.2s;
    border-radius: 8px;
}

.mobile-menu-toggle:hover {
    background: rgba(0, 0, 0, 0.05);
}

@media (max-width: 900px) {
    .header-inner {
        position: relative;
    }

    .mobile-menu-toggle {
        display: block;
    }

    .header-right {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: var(--surface);
        flex-direction: column !important;
        align-items: stretch !important;
        padding: 24px;
        gap: 20px !important;
        border-bottom: 2px solid var(--primary);
        box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
        z-index: 2000;
    }

    .header-right.active {
        display: flex;
        animation: slideDown 0.3s ease-out;
    }

    .header-lang {
        margin: 0 !important;
        padding: 0 0 16px 0 !important;
        border-left: none !important;
        border-bottom: 1px solid var(--border-color);
        justify-content: center;
        width: 100%;
    }

    .header-user {
        flex-direction: column;
        gap: 16px;
        background: none;
        border: none;
        padding: 0;
    }

    /* Restore text for menu drawer buttons */
    #header-menu .btn {
        width: 100% !important;
        height: auto !important;
        padding: 12px !important;
        font-size: 14px !important;
        justify-content: center !important;
    }

    .user-details {
        align-items: center !important;
    }

    .user-sep {
        display: none !important;
    }

    .logout-header-btn,
    .login-header-btn {
        width: 100%;
        padding: 12px !important;
    }

    .breadcrumb-inner {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }

    .breadcrumb-inner>div:last-child {
        width: 100%;
    }

    .header-actions,
    .breadcrumb-inner>div:last-child {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
    }

    /* Ensure action buttons wrap nicely */
    .btn {
        flex: 1 1 auto;
        min-width: fit-content;
    }
}

@media (max-width: 768px) {
    .page-header h1 {
        font-size: 28px;
    }

    .grid-2-1,
    .grid-1-1,
    .grid-sidebar {
        grid-template-columns: 1fr !important;
    }

    .sidebar-panel {
        position: static;
        margin-bottom: 24px;
    }

    .header-user {
        padding: 4px 8px;
    }

    .header-user span:not(.btn) {
        display: none;
        /* Hide name/email on very small screens to save space */
    }

    .header-user .btn-sm {
        margin-left: 0;
    }

    .hide-mobile {
        display: none !important;
    }

    /* Table Responsiveness */
    .table-responsive {
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        border: 1px solid var(--border-color);
        border-radius: var(--border-radius);
        margin-bottom: 24px;
    }

    .table-responsive table {
        border: none;
        margin-bottom: 0;
        table-layout: auto !important;
    }

    /* Card Padding */
    .card {
        padding: 20px;
    }

    /* Login Page Adjustments */
    .login-box {
        width: 95% !important;
        padding: 24px !important;
    }

    /* Modal sizing */
    .modal {
        width: 95%;
        max-height: 90vh;
    }
}

@media (max-width: 480px) {
    .logo-title {
        font-size: 20px !important;
    }

    .header-left img {
        height: 48px !important;
    }

    .page-header h1 {
        font-size: 24px;
    }

    .btn {
        width: 100%;
        display: flex;
    }

    .header .btn {
        width: auto;
        display: inline-flex;
    }
}
/* Rich text: formatted content from the WYSIWYG editor */
.rich-text p {
    margin: 0 0 0.6em 0;
}

.rich-text p:last-child,
.rich-text ul:last-child,
.rich-text ol:last-child,
.rich-text table:last-child {
    margin-bottom: 0;
}

.rich-text ul,
.rich-text ol {
    margin: 0 0 0.6em 0;
    padding-left: 1.6em;
}

.rich-text table {
    width: 100%;
    table-layout: fixed;
    border-collapse: collapse;
    border: none;
    border-radius: 0;
    background: none;
    overflow: visible;
    margin: 0 0 0.6em 0;
}

/* Reset the app's own table look inside rich text */
.rich-text table th,
.rich-text table td,
.rich-text table tr:last-child td,
.rich-text table tr:hover td {
    border: 1px solid var(--border-color);
    padding: 6px 10px;
    vertical-align: top;
    text-align: left;
    font-size: inherit;
    font-weight: inherit;
    color: inherit;
    background: none;
    overflow-wrap: anywhere;
}

.rich-text table th {
    font-weight: 600;
}

/* Rich text editor */
.rt-editor {
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    background-color: var(--surface);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.rt-editor:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(15, 23, 42, 0.1);
}

.rt-editor.rt-invalid {
    border-color: var(--danger);
}

.rt-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 2px;
    padding: 6px 8px;
    border-bottom: 1px solid var(--border-color);
}

.rt-table-tools {
    background: rgba(100, 116, 139, 0.06);
    border-bottom: none;
    border-top: 1px solid var(--border-color);
}

.rt-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
    padding: 0 8px;
    border: none;
    border-radius: 6px;
    background: none;
    color: var(--text-secondary);
    font-size: 15px;
    font-family: inherit;
    cursor: pointer;
}

.rt-btn:hover {
    background: rgba(100, 116, 139, 0.12);
    color: var(--text-primary);
}

.rt-btn.active {
    background: rgba(100, 116, 139, 0.22);
    color: var(--text-primary);
}

.rt-btn-text {
    font-size: 12px;
    font-weight: 600;
}

.rt-sep {
    width: 1px;
    height: 20px;
    margin: 0 6px;
    background: var(--border-color);
}

.rt-content {
    min-height: 120px;
    padding: 12px 16px;
    font-size: 15px;
    line-height: 1.6;
    color: var(--text-primary);
    outline: none;
    overflow-wrap: anywhere;
}

.rt-message {
    margin-top: 6px;
    font-size: 13px;
    color: var(--danger);
}

/* Attachments field (js/attachments.js) */
.attachments-field ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.attachments-existing li,
.attachments-selected li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 12px;
    margin-bottom: 6px;
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    font-size: 14px;
    overflow-wrap: anywhere;
}

.attachments-remove {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--text-muted);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
}

.attachments-remove:hover {
    background: var(--danger-bg);
    color: var(--danger);
}

.attachments-drop {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 18px;
    margin: 0 0 8px;
    border: 2px dashed var(--border-color);
    border-radius: 12px;
    background: #f8fafc;
    color: #64748b;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.attachments-drop:hover {
    border-color: var(--primary);
    background: #f0f7ff;
}

.attachments-drop input[type="file"] {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.attachments-hint {
    font-size: 12px;
    color: var(--text-muted);
}

/* Static text field: fixed text from the template, not editable in cases */
.static-text-block {
    padding: 14px 16px;
    background: #f8fafc;
    border-left: 3px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-primary);
}

.static-text-heading {
    font-weight: 600;
    margin-bottom: 8px;
}
