/* Page Header Styles */
.page-header-container {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-areas: "title menus";
    gap: 1rem;
    align-items: start;
    width: 100%;
    min-height: auto;
    height: auto;
    position: sticky;
    top: 0;
    z-index: 10;
}

/* Responsive layout for smaller screens */
@media (max-width: 768px) {
    .page-header-container {
        grid-template-columns: 1fr;
        grid-template-areas:
            "title"
            "menus";
        gap: 0.5rem;
        min-height: auto;
        height: auto;
    }

    .page-header-menus {
        justify-content: start;
        align-items: start;
    }
}

.page-header-title {
    grid-area: title;
    min-width: 0;
    align-self: start;
}

.page-header-menus {
    grid-area: menus;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(80px, max-content));
    gap: 1rem;
    justify-content: end;
    align-items: start;
    align-self: start;
}

.menu-item {
    justify-self: end;
    min-width: 0;
    max-width: fit-content;
    align-self: start;
}

.page-header {
    font-size: 1.5rem;
    font-weight: bold;
    margin-bottom: 0;
    color: #333;
}

/* Dropdown Menu Styles */
.dropdown-content {
    min-width: 8rem;
    padding: 0.5rem;
    border-radius: 0.375rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    background-color: white;
    z-index: 50;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s, visibility 0.2s;
    position: absolute;
    top: calc(100% - 5px); /* Reduce the gap */
    right: 0;
}

/* Dropdown hover behavior */
.dropdown, .dropdown-hover, .dropdown-end {
    position: relative;
}

/* Add a pseudo-element to bridge the gap */
.dropdown-hover::after {
    content: '';
    position: absolute;
    height: 20px; /* Height of the bridge */
    width: 100%;
    bottom: -10px; /* Position it to overlap both elements */
    left: 0;
    z-index: 49; /* Below the dropdown but above other elements */
    pointer-events: none; /* Don't interfere with mouse events */
}

/* Add a delay when hiding the dropdown */
.dropdown-content {
    transition: opacity 0.2s, visibility 0s 0.5s; /* Delay hiding by 0.5s */
}

.dropdown-hover:hover .dropdown-content {
    opacity: 1;
    visibility: visible;
    transition: opacity 0.2s, visibility 0s; /* No delay when showing */
}

/* Dropdown menu items display in a column */
.dropdown .dropdown-content,
.dropdown-hover .dropdown-content,
.dropdown-end .dropdown-content,
ul.dropdown-content {
    display: block !important;
    list-style: none !important;
}

.dropdown .dropdown-content li,
.dropdown-hover .dropdown-content li,
.dropdown-end .dropdown-content li,
ul.dropdown-content li {
    margin-bottom: 0.25rem !important;
}

.dropdown .dropdown-content a,
.dropdown .dropdown-content button,
.dropdown-hover .dropdown-content a,
.dropdown-hover .dropdown-content button,
.dropdown-end .dropdown-content a,
.dropdown-end .dropdown-content button,
ul.dropdown-content a,
ul.dropdown-content button {
    display: block !important;
    padding: 0.5rem 1rem !important;
    text-decoration: none !important;
    color: #333 !important;
    border-radius: 0.25rem !important;
    transition: background-color 0.2s !important;
    white-space: nowrap !important;
    width: 100% !important;
}

.dropdown .dropdown-content a:hover,
.dropdown .dropdown-content button:hover,
.dropdown-hover .dropdown-content a:hover,
.dropdown-hover .dropdown-content button:hover,
.dropdown-end .dropdown-content a:hover,
.dropdown-end .dropdown-content button:hover,
ul.dropdown-content a:hover,
ul.dropdown-content button:hover {
    background-color: #f3f4f6 !important;
}

/* Language-specific styles */
[lang="zh"] {
    font-family: 'Noto Sans SC', 'Microsoft YaHei', sans-serif;
    font-size: 1rem; /* Adjust size for Chinese characters */
}

/* General font settings */
body {
    font-family: 'Roboto', 'Noto Sans', sans-serif;
}

/* Card and Markdown Content Styles */
.card-body h2 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-top: 1rem;
    margin-bottom: 0.5rem;
    color: #333;
    border-bottom: 1px solid #e5e7eb;
    padding-bottom: 0.5rem;
}

/* Button styles */
.btn-ghost {
    background-color: transparent;
    border: 1px solid transparent;
}

.btn-ghost:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

.btn-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem;
}

/* Page Header Styles */
.page-header-container {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-areas: "title menus";
    gap: 1rem;
    align-items: start;
    width: 100%;
    min-height: auto;
    height: auto;
    position: sticky;
    top: 0;
    z-index: 10;
}

/* Responsive layout for smaller screens */
@media (max-width: 768px) {
    .page-header-container {
        grid-template-columns: 1fr;
        grid-template-areas:
            "title"
            "menus";
        gap: 0.5rem;
        min-height: auto;
        height: auto;
    }

    .page-header-menus {
        justify-content: start;
        align-items: start;
    }
}

.page-header-title {
    grid-area: title;
    min-width: 0;
    align-self: start;
}

.page-header-menus {
    grid-area: menus;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(80px, max-content));
    gap: 1rem;
    justify-content: end;
    align-items: start;
    align-self: start;
}

.menu-item {
    justify-self: end;
    min-width: 0;
    max-width: fit-content;
    align-self: start;
}

.page-header {
    font-size: 1.5rem;
    font-weight: bold;
    margin-bottom: 0;
    color: #333;
}

/* Dropdown Menu Styles */
.dropdown-content {
    min-width: 8rem;
    padding: 0.5rem;
    border-radius: 0.375rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    background-color: white;
    z-index: 50;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s, visibility 0.2s;
    position: absolute;
    top: calc(100% - 5px); /* Reduce the gap */
    right: 0;
}

/* Dropdown hover behavior */
.dropdown, .dropdown-hover, .dropdown-end {
    position: relative;
}

/* Add a pseudo-element to bridge the gap */
.dropdown-hover::after {
    content: '';
    position: absolute;
    height: 20px; /* Height of the bridge */
    width: 100%;
    bottom: -10px; /* Position it to overlap both elements */
    left: 0;
    z-index: 49; /* Below the dropdown but above other elements */
    pointer-events: none; /* Don't interfere with mouse events */
}

/* Add a delay when hiding the dropdown */
.dropdown-content {
    transition: opacity 0.2s, visibility 0s 0.5s; /* Delay hiding by 0.5s */
}

.dropdown-hover:hover .dropdown-content {
    opacity: 1;
    visibility: visible;
    transition: opacity 0.2s, visibility 0s; /* No delay when showing */
}

/* Dropdown menu items display in a column */
.dropdown .dropdown-content,
.dropdown-hover .dropdown-content,
.dropdown-end .dropdown-content,
ul.dropdown-content {
    display: block !important;
    list-style: none !important;
}

.dropdown .dropdown-content li,
.dropdown-hover .dropdown-content li,
.dropdown-end .dropdown-content li,
ul.dropdown-content li {
    margin-bottom: 0.25rem !important;
}

.dropdown .dropdown-content a,
.dropdown .dropdown-content button,
.dropdown-hover .dropdown-content a,
.dropdown-hover .dropdown-content button,
.dropdown-end .dropdown-content a,
.dropdown-end .dropdown-content button,
ul.dropdown-content a,
ul.dropdown-content button {
    display: block !important;
    padding: 0.5rem 1rem !important;
    text-decoration: none !important;
    color: #333 !important;
    border-radius: 0.25rem !important;
    transition: background-color 0.2s !important;
    white-space: nowrap !important;
    width: 100% !important;
}

.dropdown .dropdown-content a:hover,
.dropdown .dropdown-content button:hover,
.dropdown-hover .dropdown-content a:hover,
.dropdown-hover .dropdown-content button:hover,
.dropdown-end .dropdown-content a:hover,
.dropdown-end .dropdown-content button:hover,
ul.dropdown-content a:hover,
ul.dropdown-content button:hover {
    background-color: #f3f4f6 !important;
}

/* Language-specific styles */
[lang="zh"] {
    font-family: 'Noto Sans SC', 'Microsoft YaHei', sans-serif;
    font-size: 1rem; /* Adjust size for Chinese characters */
}

/* General font settings */
body {
    font-family: 'Roboto', 'Noto Sans', sans-serif;
}

/* Layout replacements for removed Tailwind */
.page-root {
    min-height: 100vh;
    overflow: hidden;
}
.page-content {
    display: flex;
    justify-content: center;
}
.page-container {
    width: 100%;
    max-width: none;
}
.page-section {
    padding: 1rem;
    display: flex;
    justify-content: center;
}

/* Card and Markdown Content Styles */
.card {
    background-color: #ffffff;
    border-radius: 0.5rem;
    box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -4px rgba(0,0,0,0.1);
    border: 1px solid #4b5563; /* gray-600 approx */
    margin-bottom: 1rem;
}
.card:last-child {
    margin-bottom: 0;
}
.card-body {
    padding: 1rem;
}
@media (min-width: 768px) {
    .card-body { padding: 1.5rem; }
}
.card-header {
    /* existing header styles can remain overridden from component or inline */
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background-color: #2563eb; /* blue-600 */
    color: #fff;
    font-weight: 500;
    border-radius: 0.375rem;
    border: none;
    transition: background-color 0.15s ease-in-out;
}
.btn:hover {
    background-color: #1d4ed8; /* blue-700 */
}
.btn-primary { /* alias */
    background-color: #2563eb;
}
.button-icon svg {
    width: 20px;
    height: 20px;
    display: inline-block;
}
.button-label { display: inline-block; }

/* Horizontal Divider */
.cotton-horizontal-divider {
    width: 100%;
    height: 1px;
    background-color: #e5e7eb; /* Light gray color, matching common UI patterns */
    margin: 1rem 0;
    border: none;
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .cotton-horizontal-divider {
        background-color: #374151; /* Darker gray for dark mode */
    }
}

/* Ensure cards inside page-section occupy full available width */
.page-section > .card {
    width: 100%;
    max-width: 100%;
}

/* Fit mode for narrow pages like login/welcome */
.page-container.fit .page-section > .card {
    width: auto !important;
    max-width: none;
}

/* Modal styles */
.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: auto;
    background: rgba(0,0,0,0.5);
}
.modal-backdrop .modal-card {
    width: 100%;
    max-width: 640px;
    margin: 2rem;
}
.modal-card .card-header {
    background-color: #f3f4f6; /* light gray similar to other headers */
    border-bottom: 1px solid #e5e7eb;
    padding: 0.75rem 1rem; /* slightly smaller than default */
}
.modal-card .card-title {
    font-size: 1rem;
    line-height: 1.5rem;
    margin: 0;
}
.modal-card .card-body {
    padding: 1rem;
}
.modal-card .card-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    border-top: 1px solid #e5e7eb;
    background: #fafafa;
}

/* Client list row behavior */
.client-row, .client-row * {
    cursor: pointer;
}
.client-row:hover {
    font-weight: 600;
}

/* Global table styling */
table {
    width: 100%;
    border-collapse: collapse;
}

thead th {
    background-color: #f3f4f6; /* light gray header */
    color: #111827; /* near-black text */
    font-weight: 600;
    text-align: left;
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid #e5e7eb;
}

tbody td {
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid #eef2f7; /* subtle row divider */
}

/* Zebra striping for readability */
tbody tr:nth-child(even) {
    background-color: #fafafa;
}

tbody tr.client-row:hover {
    background-color: #f3f4f6; /* gentle hover highlight */
}
