/**
 * Quản lý Công văn - Frontend Stylesheet v1.2.0
 * Bao gồm styles cho danh sách công văn và form nhập liệu frontend.
 */

/* --- Reset & Base Styles (Optional but recommended) --- */
.qlcv-cong-van-list-wrapper *,
.qlcv-frontend-form-wrapper *,
.qlcv-cong-van-list-wrapper *::before,
.qlcv-frontend-form-wrapper *::before,
.qlcv-cong-van-list-wrapper *::after,
.qlcv-frontend-form-wrapper *::after {
    box-sizing: border-box; /* Make sizing more intuitive */
}

/* --- General Styles --- */
.qlcv-cong-van-list-wrapper,
.qlcv-frontend-form-wrapper {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    margin-bottom: 2.5em;
    clear: both;
    line-height: 1.6;
    color: #495057; /* Default text color */
}

/* Helper class for screen readers */
.screen-reader-text {
	border: 0;
	clip: rect(1px, 1px, 1px, 1px);
	clip-path: inset(50%);
	height: 1px;
	margin: -1px;
	overflow: hidden;
	padding: 0;
	position: absolute !important;
	width: 1px;
	word-wrap: normal !important;
}

/* --- Styles for [danh_sach_cong_van] Shortcode --- */

/* Filter Form */
.qlcv-filter-form {
    background-color: #f8f9fa; /* Light background */
    padding: 20px;
    margin-bottom: 25px;
    border: 1px solid #dee2e6; /* Soft border */
    border-radius: 6px; /* Rounded corners */
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.qlcv-filter-row {
    display: flex;
    flex-wrap: wrap;
    gap: 15px 20px; /* Spacing between items */
    align-items: flex-end; /* Align items to bottom */
}

.qlcv-filter-item {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    min-width: 160px;
}

.qlcv-filter-item label {
    font-weight: 600;
    margin-bottom: 6px;
    font-size: 0.875em;
    color: #495057;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.qlcv-filter-item input[type="search"],
.qlcv-filter-item select {
    padding: 9px 12px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    width: 100%;
    background-color: #fff;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    font-size: 0.95em;
    color: #495057;
}
.qlcv-filter-item input[type="search"]::placeholder {
    color: #adb5bd;
}

.qlcv-filter-item input[type="search"]:focus,
.qlcv-filter-item select:focus {
    border-color: #80bdff; /* Blue focus color */
    outline: 0;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25); /* Focus glow */
}

.qlcv-filter-item input[type="search"] {
    flex-basis: 280px; /* Make search wider */
}

.qlcv-filter-submit {
    flex-grow: 0; /* Prevent button group from growing */
    min-width: auto;
    display: flex;
    gap: 12px;
    align-items: center;
    padding-bottom: 1px; /* Align with inputs */
}

.qlcv-filter-submit button[type="submit"] {
    padding: 9px 18px;
    background-color: #007bff; /* Blue */
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
    transition: background-color 0.2s ease, transform 0.1s ease;
    font-size: 0.95em;
}
.qlcv-filter-submit button[type="submit"]:hover {
    background-color: #0056b3; /* Darker Blue */
}
.qlcv-filter-submit button[type="submit"]:active {
    transform: translateY(1px); /* Press effect */
}

.qlcv-clear-filter {
    color: #6c757d; /* Gray */
    text-decoration: none;
    font-size: 0.9em;
    cursor: pointer;
    padding: 5px 0;
    border-bottom: 1px dotted transparent;
    transition: color 0.2s ease, border-color 0.2s ease;
}
.qlcv-clear-filter:hover {
    color: #dc3545; /* Red */
    border-bottom-color: #dc3545;
}

/* Data Table */
.qlcv-cong-van-table-wrapper {
    border-radius: 6px;
    overflow: hidden; /* Important for border-radius on table */
    box-shadow: 0 3px 8px rgba(0,0,0,0.08);
    margin-bottom: 25px;
    border: 1px solid #dee2e6;
}

.qlcv-cong-van-table {
    width: 100%;
    border-collapse: collapse;
    background-color: #fff;
    font-size: 0.95em;
}

.qlcv-cong-van-table th,
.qlcv-cong-van-table td {
    padding: 12px 15px;
    text-align: left;
    vertical-align: middle; /* Align content vertically center */
    border-bottom: 1px solid #dee2e6; /* Horizontal lines */
}
.qlcv-cong-van-table tr:last-child td {
    border-bottom: none; /* Remove border for last row */
}

.qlcv-cong-van-table thead th {
    background-color: #e9ecef; /* Light Gray Header */
    font-weight: 600;
    color: #495057; /* Dark Gray Text */
    white-space: nowrap;
    text-transform: uppercase;
    font-size: 0.85em;
    letter-spacing: 0.5px;
    border-bottom-width: 2px; /* Thicker bottom border for header */
    border-color: #ced4da;
}

.qlcv-cong-van-table tbody tr {
    transition: background-color 0.2s ease;
}
.qlcv-cong-van-table tbody tr:hover {
    background-color: #f1f3f5; /* Lighter Gray Hover */
}

/* Table Cell Specific Styles */
.qlcv-cong-van-table td[data-label*="Số/Ký hiệu"] {
     font-family: monospace; /* Monospace font for identifiers */
     color: #17a2b8; /* Teal color */
     font-weight: 500;
}
.qlcv-cong-van-table td[data-label*="Ngày ban hành"] {
    white-space: nowrap;
    color: #6c757d; /* Gray */
}
.qlcv-cong-van-table td[data-label*="Trích yếu"] {
    font-weight: 500;
    color: #343a40; /* Darker text for main content */
}
.qlcv-cong-van-table td[data-label*="Loại VB"],
.qlcv-cong-van-table td[data-label*="ĐV Ban hành"],
.qlcv-cong-van-table td[data-label*="Luồng"] {
    font-size: 0.9em;
    color: #6c757d; /* Gray for secondary info */
}
.qlcv-cong-van-table td a { /* Download link style */
    color: #007bff; /* Blue */
    text-decoration: none;
    transition: color 0.2s ease;
    display: inline-flex; /* Align icon nicely */
    align-items: center;
}
.qlcv-cong-van-table td a:hover {
    color: #0056b3; /* Darker Blue */
}
.qlcv-cong-van-table td a .dashicons {
    font-size: 1.3em;
    vertical-align: middle;
    text-decoration: none !important;
    color: inherit; /* Icon color follows link color */
    margin-right: 3px;
    line-height: 1;
}

/* Pagination */
.qlcv-pagination {
    margin-top: 30px;
    text-align: center;
    clear: both;
}
.qlcv-pagination ul.page-numbers {
    display: inline-block;
    padding-left: 0;
    margin: 0;
    list-style: none;
}
.qlcv-pagination ul.page-numbers li {
    display: inline;
    margin: 0 3px;
}
.qlcv-pagination ul.page-numbers li .page-numbers {
    display: inline-block;
    padding: 8px 14px;
    border: 1px solid #dee2e6;
    color: #007bff; /* Blue */
    text-decoration: none;
    background-color: #fff;
    border-radius: 4px;
    transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
    font-weight: 500;
}
.qlcv-pagination ul.page-numbers li .page-numbers.current,
.qlcv-pagination ul.page-numbers li a.page-numbers:hover {
    background-color: #007bff; /* Blue */
    color: #fff; /* White */
    border-color: #007bff;
}
.qlcv-pagination ul.page-numbers li .page-numbers.dots {
    border: none;
    background: none;
    padding: 8px 5px;
    color: #6c757d; /* Gray */
}

/* No Results Message */
.qlcv-no-results {
    background-color: #fff3cd; /* Light Yellow */
    color: #856404; /* Dark Yellow/Brown */
    border: 1px solid #ffeeba;
    padding: 15px 20px;
    border-radius: 6px;
    margin-top: 20px;
    text-align: center;
}
.qlcv-no-results a {
    color: #856404;
    font-weight: 600;
    text-decoration: underline;
}
.qlcv-no-results a:hover {
    text-decoration: none;
}

/* --- Styles for [them_cong_van_form] Shortcode --- */
.qlcv-frontend-form-wrapper {
    background-color: #fff;
    padding: 25px 30px;
    border: 1px solid #e9ecef; /* Lighter border for form */
    border-radius: 8px; /* Slightly more rounded corners */
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    margin-top: 2em;
}

.qlcv-frontend-form-wrapper h2 { /* Optional Title Styling */
    margin-top: 0;
    margin-bottom: 20px;
    font-size: 1.5em;
    color: #343a40;
    border-bottom: 1px solid #dee2e6;
    padding-bottom: 10px;
}

/* Form Grid Layout */
.qlcv-form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); /* Responsive grid */
    gap: 20px 25px;
    margin-bottom: 25px;
}
.qlcv-form-group-full {
    grid-column: 1 / -1; /* Span full width */
}

.qlcv-form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
    font-size: 0.9em;
    color: #495057;
}
.qlcv-form-group label .required {
    color: #dc3545; /* Red asterisk */
    font-weight: bold;
    margin-left: 3px;
}

.qlcv-form-group input[type="text"],
.qlcv-form-group input[type="date"],
.qlcv-form-group input[type="file"],
.qlcv-form-group select,
.qlcv-form-group textarea {
    display: block;
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #ced4da;
    border-radius: 5px;
    background-color: #fff;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    font-size: 1em;
    color: #495057;
}
.qlcv-form-group input[type="file"] {
    padding: 8px;
    background-color: #f8f9fa; /* Slightly different background for file input */
    cursor: pointer;
}
.qlcv-form-group input[type="file"]::file-selector-button { /* Style the button inside input[type=file] */
    padding: 8px 12px;
    margin-right: 10px;
    background-color: #6c757d; /* Gray button */
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s ease;
}
.qlcv-form-group input[type="file"]::file-selector-button:hover {
    background-color: #5a6268; /* Darker Gray */
}


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

.qlcv-form-group input:focus,
.qlcv-form-group select:focus,
.qlcv-form-group textarea:focus {
    border-color: #80bdff; /* Blue focus */
    outline: 0;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

.qlcv-form-group small {
    display: block;
    margin-top: 6px;
    font-size: 0.85em;
    color: #6c757d; /* Gray help text */
}

/* Form Submit Area */
.qlcv-form-submit-area {
    margin-top: 15px;
    text-align: right;
}

.qlcv-submit-button {
    display: inline-block;
    padding: 12px 25px;
    background-color: #28a745; /* Green */
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1.05em;
    font-weight: 600;
    text-align: center;
    transition: background-color 0.2s ease, transform 0.1s ease;
}
.qlcv-submit-button:hover {
    background-color: #218838; /* Darker Green */
}
.qlcv-submit-button:active {
    transform: translateY(1px);
}

/* Form Messages (Success/Error) */
.qlcv-message {
    padding: 15px 20px;
    margin-bottom: 20px;
    border-radius: 5px;
    border: 1px solid transparent;
}
.qlcv-message.qlcv-success {
    color: #155724; /* Dark Green Text */
    background-color: #d4edda; /* Light Green Background */
    border-color: #c3e6cb;
}
.qlcv-message.qlcv-error {
    color: #721c24; /* Dark Red Text */
    background-color: #f8d7da; /* Light Red Background */
    border-color: #f5c6cb;
}
.qlcv-message.qlcv-error ul {
    margin-top: 10px;
    margin-bottom: 0;
    padding-left: 20px;
}
.qlcv-message a {
    color: inherit; /* Link color matches message text */
    font-weight: bold;
    text-decoration: underline;
}
.qlcv-message a:hover {
    text-decoration: none;
}

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

/* Tablet and Smaller Desktops */
@media screen and (max-width: 992px) {
    .qlcv-filter-item input[type="search"] {
        flex-basis: auto; /* Allow search to shrink */
    }
}

/* Mobile Devices */
@media screen and (max-width: 768px) {
    /* Filter Form Responsive */
    .qlcv-filter-row {
        flex-direction: column;
        align-items: stretch; /* Make items full width */
        gap: 15px;
    }
    .qlcv-filter-item {
        min-width: 100%;
    }
    .qlcv-filter-submit {
       justify-content: flex-start;
       margin-top: 10px;
       gap: 15px;
    }
    .qlcv-filter-submit button[type="submit"] {
        flex-grow: 1; /* Make button wider */
    }
    .qlcv-clear-filter {
        padding: 9px 0;
    }

    /* Data Table Responsive (Card View) */
    .qlcv-cong-van-table-wrapper {
        box-shadow: none;
        border: none;
        border-radius: 0;
        overflow: visible;
    }
    .qlcv-cong-van-table thead {
        display: none; /* Hide table header */
    }
    .qlcv-cong-van-table tbody tr {
        display: block;
        margin-bottom: 20px;
        border: 1px solid #dee2e6;
        border-radius: 6px;
        background-color: #fff;
        box-shadow: 0 2px 4px rgba(0,0,0,0.06);
        padding: 5px;
    }
     .qlcv-cong-van-table tbody td {
        display: block;
        text-align: right; /* Align value to the right */
        border: none;
        border-bottom: 1px dashed #e9ecef; /* Dashed separator */
        padding-left: 45%; /* Space for label */
        padding-top: 10px;
        padding-bottom: 10px;
        padding-right: 15px;
        position: relative;
        white-space: normal; /* Allow text wrap */
        min-height: 24px;
    }
    .qlcv-cong-van-table tbody td::before {
        content: attr(data-label); /* Use data-label as label */
        position: absolute;
        left: 15px;
        width: calc(45% - 25px); /* Label width */
        font-weight: 600;
        text-align: left;
        white-space: nowrap;
        color: #6c757d; /* Gray label */
        font-size: 0.9em;
    }
     .qlcv-cong-van-table tbody td:last-child {
        border-bottom: none; /* No border for last cell in card */
    }
    .qlcv-cong-van-table tbody td[data-label*="Trích yếu"] {
        font-weight: bold;
        font-size: 1.05em;
    }
    .qlcv-cong-van-table tbody td[data-label*="Tệp tin"] a {
        display: inline-block;
    }
    .qlcv-cong-van-table tbody td[data-label*="Tệp tin"] {
         text-align: right;
         padding-top: 8px;
         padding-bottom: 8px;
    }

    /* Frontend Form Responsive */
    .qlcv-frontend-form-wrapper {
        padding: 20px;
    }
    .qlcv-form-grid {
        grid-template-columns: 1fr; /* Single column */
        gap: 15px;
    }
    .qlcv-form-group-full {
        grid-column: auto; /* Reset span */
    }
    .qlcv-form-submit-area {
        text-align: center; /* Center button */
    }
    .qlcv-submit-button {
        width: 100%; /* Full width button */
    }

    /* Pagination Responsive */
     .qlcv-pagination ul.page-numbers li .page-numbers {
        padding: 6px 10px; /* Smaller padding */
        font-size: 0.9em;
    }
}

/* --- End of Styles --- */