/**
 * Trilobita DocVault - Admin Styles
 *
 * @package TrilobitaDocVault
 */

/* ── Upload Interface ── */

.trdv-upload-wrap h4 {
    margin-top: 0;
}

.trdv-dropzone {
    border: 2px dashed #c3c4c7;
    border-radius: 4px;
    padding: 30px 20px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s, background-color 0.2s;
    margin-bottom: 15px;
    position: relative;
}

.trdv-dropzone:hover,
.trdv-dropzone.trdv-dragover {
    border-color: var(--wp-admin-theme-color, #2271b1);
    background-color: #f0f6fc;
}

.trdv-dropzone .dashicons-upload {
    font-size: 48px;
    width: 48px;
    height: 48px;
    color: #c3c4c7;
    margin-bottom: 10px;
}

.trdv-dropzone:hover .dashicons-upload,
.trdv-dropzone.trdv-dragover .dashicons-upload {
    color: var(--wp-admin-theme-color, #2271b1);
}

.trdv-dropzone p {
    margin: 5px 0;
    color: #646970;
}

.trdv-allowed-types {
    font-size: 12px;
    color: #a7aaad !important;
}

.trdv-file-input {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

/* ── File Preview ── */

.trdv-file-preview {
    background: #f0f6fc;
    border: 1px solid #c3c4c7;
    border-radius: 4px;
    padding: 10px 15px;
    margin-bottom: 15px;
}

.trdv-file-preview p {
    margin: 0;
}

.trdv-remove-file {
    color: #b32d2e;
    margin-left: 10px;
    text-decoration: none;
}

.trdv-remove-file:hover {
    color: #a00;
}

/* ── Current File Info Table ── */

.trdv-file-info-table {
    margin-bottom: 15px;
}

.trdv-file-info-table th {
    width: 120px;
    font-weight: 600;
}

/* ── Document Title ── */

.trdv-title-wrap {
    margin-bottom: 15px;
    padding: 15px;
    background: #f6f7f7;
    border: 1px solid #c3c4c7;
    border-radius: 4px;
}

.trdv-title-wrap label {
    display: block;
    margin-bottom: 8px;
}

.trdv-title-wrap input[type="text"] {
    font-size: 1.4em;
    padding: 8px 12px;
    height: auto;
}

.trdv-title-wrap .description {
    margin-top: 8px;
    font-style: italic;
}

/* ── Version Notes ── */

.trdv-version-notes-wrap {
    margin-bottom: 15px;
}

.trdv-version-notes-wrap label {
    display: block;
    margin-bottom: 5px;
}

/* ── Upload Progress ── */

.trdv-upload-progress {
    margin-bottom: 15px;
}

.trdv-progress-bar {
    background: #dcdcde;
    border-radius: 3px;
    height: 20px;
    overflow: hidden;
    margin-bottom: 5px;
}

.trdv-progress-fill {
    background: var(--wp-admin-theme-color, #2271b1);
    height: 100%;
    width: 0;
    transition: width 0.3s ease;
    border-radius: 3px;
}

.trdv-progress-text {
    font-size: 12px;
    color: #646970;
}

/* ── Version Limit Warning Banner ── */

.trdv-version-limit-warning {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    background: #fff8e5;
    border: 1px solid #dba617;
    border-left: 4px solid #dba617;
    border-radius: 4px;
    padding: 14px 16px;
    margin-bottom: 15px;
}

.trdv-version-limit-warning .dashicons-warning {
    font-size: 22px;
    width: 22px;
    height: 22px;
    color: #996800;
    flex-shrink: 0;
    margin-top: 1px;
}

.trdv-version-limit-warning-body {
    flex: 1;
}

.trdv-version-limit-warning-body p {
    margin: 0 0 8px;
    color: #1d2327;
}

.trdv-version-limit-warning-body p:last-child {
    margin-bottom: 0;
}

.trdv-version-limit-warning-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.trdv-version-limit-cancel {
    color: #646970;
    text-decoration: none;
    font-size: 13px;
}

.trdv-version-limit-cancel:hover {
    color: var(--wp-admin-theme-color-darker-10, #135e96);
}

@keyframes trdv-shake {
    0%, 100% { transform: translateX(0); }
    20%       { transform: translateX(-6px); }
    40%       { transform: translateX(6px); }
    60%       { transform: translateX(-4px); }
    80%       { transform: translateX(4px); }
}

.trdv-warning-shake {
    animation: trdv-shake 0.6s ease;
}

/* ── Upload Messages (uses WP notice pattern) ── */

.trdv-upload-message {
    padding: 10px 15px;
    margin-bottom: 15px;
    border-left-width: 4px;
    border-left-style: solid;
    background: #fff;
    box-shadow: 0 1px 1px rgba(0, 0, 0, 0.04);
}

.trdv-upload-message.trdv-success {
    border-left-color: #00a32a;
}

.trdv-upload-message.trdv-error {
    border-left-color: #d63638;
}

.trdv-upload-message.trdv-warning {
    border-left-color: #dba617;
}

/* ── Expiry date column ── */

.trdv-expiry-expired {
    color: #d63638;
    font-weight: 600;
}

.trdv-expiry-soon {
    color: #dba617;
    font-weight: 600;
}

/* ── Similarity Results ── */

.trdv-similarity-results {
    background: #fff8e5;
    border: 1px solid #dba617;
    border-radius: 4px;
    padding: 15px;
    margin-bottom: 15px;
}

.trdv-similarity-results h4 {
    margin: 0 0 10px 0;
    color: #996800;
}

.trdv-similarity-match {
    padding: 8px 0;
    border-bottom: 1px solid #f0e6cc;
}

.trdv-similarity-match:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.trdv-similarity-actions {
    margin-top: 10px;
}

.trdv-similarity-actions .button {
    margin-right: 8px;
}

/* ── Version History Table ── */

.trdv-version-table {
    margin-top: 0;
}

.trdv-version-table .trdv-col-version {
    width: 90px;
}

.trdv-version-table .trdv-col-size {
    width: 80px;
}

.trdv-version-table .trdv-col-date {
    width: 150px;
}

.trdv-version-table .trdv-col-uploader {
    width: 120px;
}

.trdv-version-table .trdv-col-actions {
    width: 120px;
}

.trdv-current-version {
    background-color: #f0f6fc !important;
}

.trdv-badge-current {
    display: inline-block;
    background: var(--wp-admin-theme-color, #2271b1);
    color: #fff;
    font-size: 11px;
    padding: 1px 6px;
    border-radius: 3px;
    margin-left: 5px;
    vertical-align: middle;
}

.trdv-version-table .button-small {
    padding: 0 5px;
    min-height: 26px;
    line-height: 24px;
}

.trdv-version-table .button-small .dashicons {
    font-size: 16px;
    width: 16px;
    height: 16px;
}

/* ── Drag-and-Drop Sort Order ── */

.column-trdv_sort {
    width: 30px;
    padding-right: 0 !important;
}

.trdv-sort-handle {
    display: inline-block;
    cursor: grab;
    color: #a7aaad;
    font-size: 20px;
    width: 20px;
    height: 20px;
    vertical-align: middle;
    transition: color 0.15s;
}

.trdv-sort-handle:hover {
    color: var(--wp-admin-theme-color, #2271b1);
}

.trdv-sort-handle:active {
    cursor: grabbing;
}

/* Row being dragged */
.trdv-sorting-active {
    background: #f0f6fc !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

/* Placeholder row while dragging */
.trdv-sort-placeholder {
    height: 36px;
    background: #e7f3fb;
    border: 1px dashed var(--wp-admin-theme-color, #2271b1);
    visibility: visible !important;
}

/* Saved indicator */
.trdv-sort-saved {
    display: none;
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: #00a32a;
    color: #fff;
    padding: 8px 16px;
    border-radius: 4px;
    font-size: 13px;
    z-index: 9999;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

/* ── Custom List Column Styles ── */

.column-trdv_file_type {
    width: 80px;
}

.column-trdv_version {
    width: 70px;
}

.column-trdv_file_size {
    width: 90px;
}

.column-trdv_upload_date {
    width: 150px;
}

.column-trdv_uploader {
    width: 120px;
}

.column-trdv_downloads {
    width: 90px;
}

/* ── Download Statistics Metabox ── */

.trdv-download-stats-wrap h4 {
    margin: 20px 0 10px;
}

.trdv-download-stats-wrap h4:first-child {
    margin-top: 0;
}

.trdv-stats-summary {
    display: flex;
    gap: 20px;
    margin-bottom: 15px;
}

.trdv-stat-box {
    background: #f0f6fc;
    border: 1px solid #c3c4c7;
    border-radius: 4px;
    padding: 15px 25px;
    text-align: center;
}

.trdv-stat-number {
    display: block;
    font-size: 28px;
    font-weight: 600;
    color: var(--wp-admin-theme-color, #2271b1);
    line-height: 1.2;
}

.trdv-stat-label {
    display: block;
    font-size: 12px;
    color: #646970;
    margin-top: 5px;
}

.trdv-version-stats-table,
.trdv-download-log-table {
    margin-top: 0;
}

.trdv-download-log-table .trdv-col-date {
    width: 180px;
}

.trdv-download-log-table .trdv-col-version {
    width: 80px;
}

.trdv-download-log-table .trdv-col-user {
    width: 150px;
}

.trdv-download-log-table .trdv-col-ip {
    width: 130px;
}

/* ── Hide Default Editor Elements ── */

.post-type-trdv_document #titlediv,
.post-type-trdv_document #postdivrich,
.post-type-trdv_document #post-body-content > #titlewrap {
    display: none !important;
}

/* ── Access Control Metabox ── */

.trdv-access-control-wrap p {
    margin: 8px 0;
}

.trdv-access-control-wrap label {
    cursor: pointer;
}

.trdv-roles-list {
    margin-left: 20px;
    padding: 8px;
    background: #f9f9f9;
    border-radius: 4px;
}

.trdv-roles-list label {
    display: block;
    margin: 4px 0;
}

.trdv-roles-list .description {
    margin-top: 8px;
    font-size: 11px;
}

.trdv-access-upgrade-note {
    margin-top: 12px;
}

/* ── Settings Page — Card Layout ── */

.trdv-settings-card {
    background: #fff;
    border: 1px solid #c3c4c7;
    border-radius: 6px;
    margin-bottom: 20px;
    max-width: 860px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    overflow: hidden;
}

.trdv-settings-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 16px 20px;
    background: #f6f7f7;
    border-bottom: 1px solid #c3c4c7;
}

.trdv-settings-card-body-hidden + .trdv-settings-card-header,
.trdv-settings-card-header:last-child {
    border-bottom: none;
}

.trdv-settings-card-title {
    display: flex;
    align-items: center;
    gap: 12px;
}

.trdv-settings-card-title .dashicons {
    font-size: 22px;
    width: 22px;
    height: 22px;
    color: var(--wp-admin-theme-color, #2271b1);
    flex-shrink: 0;
}

.trdv-settings-card-title h3 {
    margin: 0 0 2px;
    font-size: 14px;
    font-weight: 600;
    color: #1d2327;
}

.trdv-settings-card-title p {
    margin: 0;
    font-size: 12px;
    color: #646970;
}

.trdv-settings-card-body {
    padding: 20px;
}

.trdv-card-body-hidden {
    display: none;
}

/* Toggle switch */

.trdv-toggle-switch {
    position: relative;
    display: inline-flex;
    align-items: center;
    cursor: pointer;
    flex-shrink: 0;
}

.trdv-toggle-switch input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    margin: 0;
}

.trdv-toggle-track {
    display: inline-block;
    width: 44px;
    height: 24px;
    background: #c3c4c7;
    border-radius: 12px;
    transition: background 0.2s ease;
    position: relative;
    flex-shrink: 0;
}

.trdv-toggle-track::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 18px;
    height: 18px;
    background: #fff;
    border-radius: 50%;
    transition: left 0.2s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
}

.trdv-toggle-switch input:checked + .trdv-toggle-track {
    background: var(--wp-admin-theme-color, #2271b1);
}

.trdv-toggle-switch input:checked + .trdv-toggle-track::after {
    left: 23px;
}

.trdv-toggle-switch input:focus-visible + .trdv-toggle-track {
    box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--wp-admin-theme-color, #2271b1);
}

/* Field layouts */

.trdv-field-group {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.trdv-field-row {
    display: grid;
    grid-template-columns: 180px 1fr;
    gap: 12px;
    align-items: start;
}

.trdv-field-row > label {
    padding-top: 5px;
    font-weight: 500;
    color: #1d2327;
    font-size: 13px;
}

.trdv-field-checkbox {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    cursor: pointer;
}

.trdv-field-checkbox input[type="checkbox"] {
    margin-top: 3px;
    flex-shrink: 0;
}

.trdv-field-checkbox span {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.trdv-field-checkbox strong {
    font-size: 13px;
    font-weight: 500;
    color: #1d2327;
}

.trdv-field-checkbox em {
    font-style: normal;
    font-size: 12px;
    color: #646970;
}

.trdv-field-checkbox--compact {
    align-items: center;
}

.trdv-field-checkbox--compact span {
    flex-direction: row;
    font-size: 13px;
    color: #1d2327;
}

/* Divider and sub-heading */

.trdv-card-divider {
    border: none;
    border-top: 1px solid #f0f0f1;
    margin: 4px 0;
}

.trdv-field-subheading {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 0;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #646970;
}

.trdv-field-subheading .dashicons {
    font-size: 14px;
    width: 14px;
    height: 14px;
}

/* ── Settings Page — Legacy / Misc ── */

#trdv-default-roles-list {
    margin-left: 25px;
    padding: 10px;
    background: #f9f9f9;
    border-radius: 4px;
}

#trdv-default-roles-list label {
    display: block;
    margin: 5px 0;
}

#trdv-default-roles-list .description {
    margin-top: 10px;
}

.trdv-pro-upgrade-box {
    background: #f0f7fc;
    border: 1px solid var(--wp-admin-theme-color, #0073aa);
    border-radius: 4px;
    padding: 15px 20px;
    margin-top: 10px;
}

.trdv-pro-upgrade-box h3 {
    margin-top: 0;
    color: var(--wp-admin-theme-color, #0073aa);
}

.trdv-pro-upgrade-box ul {
    margin: 10px 0 15px 20px;
}

.trdv-settings-warning {
    background: #fff8e5;
    border-left: 4px solid #dba617;
    padding: 10px 15px;
    margin-top: 15px;
}

.trdv-settings-warning .dashicons {
    color: #dba617;
    margin-right: 5px;
}

/* ── Help Page ── */

.trdv-help-wrap {
    max-width: 900px;
}

.trdv-help-section {
    background: #fff;
    padding: 20px 25px;
    margin: 20px 0;
    border: 1px solid #ccd0d4;
    border-radius: 4px;
}

.trdv-help-section h2 {
    margin-top: 0;
    padding-bottom: 10px;
    border-bottom: 1px solid #eee;
}

.trdv-help-section h3 {
    margin-top: 20px;
}

.trdv-help-section code {
    background: #f0f0f1;
    padding: 4px 8px;
    border-radius: 3px;
}

.trdv-help-section table code {
    background: none;
    padding: 0;
}

.trdv-help-section ul,
.trdv-help-section ol {
    margin-left: 20px;
}

.trdv-help-section table {
    margin-top: 10px;
}

.trdv-help-section .dashicons-info {
    color: var(--wp-admin-theme-color, #0073aa);
}

.trdv-help-pro-section {
    background: #f0f7fc;
    border-color: var(--wp-admin-theme-color, #0073aa);
}

.trdv-help-pro-section h2 {
    color: var(--wp-admin-theme-color, #0073aa);
}
