/* ===== FRONTEND ADMIN WRAPPER ===== */
.kw-frontend-admin {
    background: #fff;
    padding: 20px;
    border-radius: 4px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.kw-frontend-admin .kw-doc-topics {
    font-size: 0.9em;
}

/* ===== SELECT2 CUSTOMIZATIONS ===== */
/* Prevent Divi/theme form rules from making Select2's source <select> visible. */
.select2-hidden-accessible {
    border: 0 !important;
    clip: rect(0 0 0 0) !important;
    -webkit-clip-path: inset(50%) !important;
    clip-path: inset(50%) !important;
    height: 1px !important;
    margin: -1px !important;
    overflow: hidden !important;
    padding: 0 !important;
    position: absolute !important;
    width: 1px !important;
    white-space: nowrap !important;
}

.select2-container {
    display: inline-block !important;
    width: 100% !important;
    max-width: 100%;
    box-sizing: border-box;
    vertical-align: middle;
}

.select2-container .select2-selection--single,
.select2-container .select2-selection--multiple {
    box-sizing: border-box;
    width: 100%;
    min-height: 38px;
}

.select2-container--default .select2-selection--multiple {
    height: auto !important;
    padding: 2px 5px;
}

.select2-container--default .select2-selection--multiple .select2-selection__rendered {
    display: block !important;
    width: 100%;
    min-height: 30px;
    margin: 0;
    padding: 0;
    list-style: none;
    white-space: normal;
    box-sizing: border-box;
}

.select2-container--default .select2-selection--multiple .select2-selection__choice {
    float: left;
    max-width: calc(100% - 10px);
    margin-top: 5px;
    margin-right: 5px;
    box-sizing: border-box;
}

.select2-container--default .select2-selection--multiple .select2-search--inline {
    float: left;
    margin: 0;
    padding: 0;
    max-width: 100%;
}

.select2-container--default .select2-selection--multiple .select2-search__field {
    width: auto !important;
    min-width: 12em;
    max-width: 100%;
    height: 28px !important;
    min-height: 28px !important;
    margin: 5px 0 0 !important;
    padding: 0 4px !important;
    border: 0 !important;
    box-shadow: none !important;
    line-height: 28px !important;
    box-sizing: border-box !important;
}

/* ===== FORM CONTAINERS ===== */
#kw-topics-form-container, 
#kw-class-form-container, 
#kw-attendance-form-container, 
#kw-attendance-sheet-container, 
#kw-assignment-container {
    margin-bottom: 20px;
    padding: 20px;
    border: 1px solid #ccc;
    background: #f9f9f9;
}

.kw-form-field {
    margin-bottom: 15px;
}

.kw-form-field label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
}

.kw-form-field input[type="text"],
.kw-form-field textarea {
    width: 100%;
    padding: 8px;
    box-sizing: border-box;
    border: 1px solid #ddd;
}

/* ===== BUTTON STYLES ===== */
.button-danger {
    background: #d63638;
    color: #fff;
    border-color: #d63638;
    width: 100%;
    max-width: 200px;
    margin-bottom: 8px;
}

.button-danger:hover {
    background: #c32d2f;
    border-color: #c32d2f;
}

/* Stacked button layout for danger buttons */
.wp-list-table .button.button-danger,
.wp-list-table .kw-delete-doc-restriction,
.wp-list-table .kw-delete-topic,
.wp-list-table .kw-delete-class {
    display: block;
    width: 100%;
    text-align: center;
    margin-bottom: 8px;
}

/* Ensure danger buttons in table cells stack properly */
.wp-list-table td .button.button-danger,
.wp-list-table td .kw-delete-doc-restriction,
.wp-list-table td .kw-delete-topic,
.wp-list-table td .kw-delete-class {
    display: block;
    width: 100%;
    margin-bottom: 8px;
}

/* Light blue Edit buttons - Override custom properties */
.wp-list-table .button.button-secondary,
.wp-list-table .kw-edit-doc-restriction,
.wrap .button.button-secondary,
.wrap .kw-edit-doc-restriction,
.kw-frontend-admin .button.button-secondary,
.kw-frontend-admin .kw-edit-doc-restriction {
    --bg: #00A9F4 !important;
    --color: #ffffff !important;
    --bg--hover: #007cba !important;
    --color--hover: #ffffff !important;
    
    background: #00A9F4 !important;
    border-color: #00A9F4 !important;
    color: #ffffff !important;
    font-weight: bold !important;
    width: 100%;
    max-width: 200px;
    margin-bottom: 8px;
}

.wp-list-table .button.button-secondary:hover,
.wp-list-table .kw-edit-doc-restriction:hover,
.wrap .button.button-secondary:hover,
.wrap .kw-edit-doc-restriction:hover,
.kw-frontend-admin .button.button-secondary:hover,
.kw-frontend-admin .kw-edit-doc-restriction:hover {
    background: #007cba !important;
    border-color: #007cba !important;
    color: #ffffff !important;
    font-weight: bold !important;
}

/* Stacked button layout for tables */
.wp-list-table .button.button-secondary,
.wp-list-table .kw-edit-doc-restriction {
    display: block;
    width: 100%;
    text-align: center;
    margin-bottom: 8px;
}

/* Ensure buttons in table cells stack properly */
.wp-list-table td .button.button-secondary,
.wp-list-table td .kw-edit-doc-restriction {
    display: block;
    width: 100%;
    margin-bottom: 8px;
}

/* Specific targeting for form edit buttons */
#kw-doc-restriction-form-container .button.button-secondary,
#kw-topics-form-container .button.button-secondary,
#kw-class-form-container .button.button-secondary {
    --bg: #00A9F4 !important;
    --color: #ffffff !important;
    --bg--hover: #007cba !important;
    --color--hover: #ffffff !important;
    
    background: #00A9F4 !important;
    border-color: #00A9F4 !important;
    color: #ffffff !important;
    font-weight: bold !important;
    width: 100%;
    max-width: 200px;
    margin-bottom: 8px;
}

#kw-doc-restriction-form-container .button.button-secondary:hover,
#kw-topics-form-container .button.button-secondary:hover,
#kw-class-form-container .button.button-secondary:hover {
    background: #007cba !important;
    border-color: #007cba !important;
    color: #ffffff !important;
    font-weight: bold !important;
}

#kw-doc-paths-textarea {
    width: 100%;
    max-width: 600px;
    height: 200px;
    font-family: monospace;
}

.kw-doc-topics {
    margin: 0;
    padding-left: 15px;
}

.kw-doc-topics li {
    margin: 2px 0;
    line-height: 1.3;
}

/* Document Access Control Styles */
.restricted-doc-link {
    opacity: 0.8;
    cursor: not-allowed;
    text-decoration: line-through;
    position: relative;
    background-color: #ffffff !important;
    border: 1px solid #000 !important;
    color: red !important;
    font-weight: bold !important;
}

.restricted-doc-link::after {
    content: '🔒';
    margin-left: 4px;
    font-size: 1.2em !important;
    vertical-align: middle;
}

/* Hide loading states */
.kw-loading {
    opacity: 1 !important;
    background-image: none !important;
    cursor: default !important;
}

.kw-loading:after,
.kw-loading:before {
    display: none !important;
}

/* ===== MODAL STYLES ===== */
.kw-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 99999;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    animation: fadeIn 0.2s ease-in-out forwards;
}

@keyframes fadeIn {
    to { opacity: 1; }
}

.kw-modal-content {
    background: #fff;
    border-radius: 8px;
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 5px 30px rgba(0, 0, 0, 0.3);
}

.kw-modal-header {
    padding: 15px 20px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.kw-modal-header h3 {
    margin: 0;
    font-size: 1.3em;
    color: #23282d;
}

.kw-modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    padding: 0 10px;
    line-height: 1;
    color: #72777c;
    transition: color 0.2s;
}

.kw-modal-close:hover {
    color: #23282d;
}

.kw-modal-body {
    padding: 20px;
}

.kw-modal-footer {
    padding: 15px 20px;
    border-top: 1px solid #eee;
    text-align: right;
}

.kw-missing-classes {
    margin: 15px 0;
    list-style-type: disc;
    padding-left: 20px;
}

.kw-missing-classes li {
    margin-bottom: 8px;
    line-height: 1.4;
}

/* ===== TOPICS & CLASSES MANAGEMENT ===== */
.kw-class-topics {
    margin-top: 10px;
    padding: 10px;
    background: #f9f9f9;
    border-radius: 4px;
}

.kw-class-topics ul {
    margin: 5px 0 0 0;
    padding-left: 20px;
}

.kw-class-topics li {
    margin: 2px 0;
}

.kw-topics-covered {
    list-style-type: disc;
    margin-left: 20px;
}

.kw-topics-covered li {
    margin: 5px 0;
    line-height: 1.4;
}

.kw-class-description {
    white-space: pre-line;
    line-height: 1.5;
    margin: 8px 0;
}

/* ===== ATTENDANCE MANAGEMENT ===== */
.kw-attendee-item {
    display: flex;
    align-items: center;
    margin-bottom: 5px;
}

.kw-attendee-item input {
    margin-right: 10px;
}

.kw-attendee-item strong {
    font-weight: 600;
    color: #333;
}

.kw-attendee-item span {
    line-height: 1.4;
}

.kw-updated {
    box-shadow: 0 0 10px green;
    transition: box-shadow 0.3s ease;
}

#kw-day-attendees input[type="checkbox"]:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Guest Attendees */
.kw-guest-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid #eee;
}

.kw-guest-item:last-child {
    border-bottom: none;
}

.kw-guest-info {
    flex-grow: 1;
}

.kw-guest-name {
    font-weight: bold;
}

.kw-guest-time {
    color: #666;
    margin-left: 10px;
}

.kw-delete-guest-attendee {
    margin-left: auto;
}

/* ===== MEMBER RECORDS & TABLES ===== */
.kw-member-history table,
.kw-records-table {
    width: 100%;
    border-collapse: collapse;
}

.kw-member-history th,
.kw-records-table th {
    background-color: #f1f1f1;
    padding: 10px;
    text-align: left;
    font-weight: bold;
}

.kw-member-history td,
.kw-records-table td {
    padding: 8px 10px;
    border-bottom: 1px solid #ddd;
}

.kw-member-history tr:nth-child(even),
.kw-records-table tr:nth-child(even) {
    background-color: #f9f9f9;
}

.description {
    color: #999;
    font-style: italic;
}

/* ===== EDIT MODE STYLING ===== */
#kw-doc-restriction-form.edit-mode,
#kw-topic-form.edit-mode,
#kw-class-form.edit-mode {
    border: 3px solid #46b450 !important;
    background-color: #f7fff7 !important;
    box-shadow: 0 0 15px rgba(70, 180, 80, 0.3) !important;
    padding: 20px;
    margin-bottom: 20px;
}

#kw-doc-restriction-form.edit-mode::before,
#kw-topic-form.edit-mode::before,
#kw-class-form.edit-mode::before {
    content: "EDIT MODE - Editing Existing Item";
    display: block;
    background: #46b450;
    color: white;
    padding: 10px;
    margin: -20px -20px 20px -20px;
    font-weight: bold;
    border-radius: 3px 3px 0 0;
}

.kw-edit-highlight {
    animation: highlight 2s ease-in-out;
    background-color: #fff9e6 !important;
    border-left: 4px solid #0073aa !important;
}

@keyframes highlight {
    0% { background-color: #ffffcc; }
    100% { background-color: #fff9e6; }
}

/* ===== RESPONSIVE DESIGN ===== */
@media screen and (max-width: 782px) {
    .kw-member-history table,
    .kw-records-table {
        display: block;
        overflow-x: auto;
    }
}

@media (max-width: 768px) {
    .kw-doc-topics {
        padding-left: 10px;
    }
    
    #document-select, 
    #topic-select {
        min-width: 200px;
    }
}
/* Manage Groups drag-and-drop ordering */
#kw-groups-table .kw-group-drag-handle {
    cursor: grab;
    text-align: center;
    font-size: 20px;
    line-height: 1;
    user-select: none;
}
#kw-groups-table tr[draggable="true"] {
    cursor: move;
}
#kw-groups-table tr.kw-group-dragging {
    opacity: 0.55;
}

/* Manage Documents */
#kw-documents-table .kw-document-drag-handle{cursor:grab;text-align:center;font-size:20px;line-height:1;user-select:none}
#kw-documents-table tr[draggable="true"]{cursor:move}
#kw-documents-table tr.kw-document-dragging{opacity:.55}
.kw-document-access-list{display:grid;gap:18px}
.kw-access-rule-card{border:1px solid #0b5d2a;background:#fff}
.kw-access-rule-card>h3{margin:0;padding:12px 16px;background:#0b5d2a;color:#fff;font-size:18px}
.kw-access-rule-body{padding:16px}
.kw-access-rule-body ul{margin:8px 0 16px 22px}


/* Training Videos */
.kw-video-drag-handle{cursor:grab;font-size:20px;text-align:center;user-select:none}
.kw-video-shortcode{white-space:nowrap}
.kw-training-video{position:relative;width:100%;aspect-ratio:16/9;background:#1f1f1f center/cover no-repeat;overflow:hidden}
.kw-video-responsive{position:absolute;inset:0}
.kw-video-responsive iframe{width:100%;height:100%;border:0}
.kw-training-video-locked{display:flex;align-items:center;justify-content:center;min-height:220px}
.kw-training-video-locked:before{content:"";position:absolute;inset:0;background:rgba(0,0,0,.18)}
.kw-video-lock-overlay{position:absolute;left:0;right:0;bottom:0;z-index:2;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:6px;width:100%;max-width:none;max-height:66.666%;padding:10px 16px;box-sizing:border-box;text-align:center;background:rgba(255,255,255,.82);backdrop-filter:blur(1px);-webkit-backdrop-filter:blur(1px);border-radius:8px 8px 0 0;box-shadow:0 -2px 12px rgba(0,0,0,.22);overflow:auto;font-family:inherit;font-size:16px;line-height:1.3}
.kw-video-lock-overlay .dashicons{display:block;flex:0 0 auto;margin:0;width:24px;height:24px;font-size:24px;line-height:24px}
.kw-video-lock-overlay strong{display:block;margin:0;font-size:18px;line-height:1.2}
.kw-video-lock-help{display:block;margin:0;max-width:100%;font-size:14px;line-height:1.3;overflow-wrap:anywhere}
.kw-video-lock-overlay ul{margin:0;padding-left:18px;max-width:100%;font-size:14px;text-align:left;line-height:1.3}

.kw-video-responsive video{width:100%;height:100%;display:block;background:#000}

.kw-video-lock-overlay .kw-admin-preview-video{margin-top:2px;padding:5px 10px;min-height:0;font-size:14px;line-height:1.2;white-space:nowrap}
.kw-training-video.kw-admin-preview-loading .kw-video-lock-overlay{opacity:.72}


/* v1.6.12: Divi/FitVids wrapper compatibility for automatically locked videos. */
.fluid-width-video-wrapper.kw-video-wrapper-locked{
    padding-top:0 !important;
    height:auto !important;
}
.fluid-width-video-wrapper.kw-video-wrapper-locked > .kw-training-video-auto{
    position:relative !important;
    inset:auto !important;
    display:flex;
    width:100% !important;
    height:auto !important;
    aspect-ratio:16/9;
}


/* v1.7.0: Term management */
.kw-active-term-inline{display:inline-block;margin:0 0 18px;padding:8px 12px;background:#f0f6fc;border-left:4px solid #2271b1;border-radius:3px}
.kw-active-term-card{display:flex;align-items:center;gap:12px;flex-wrap:wrap;margin:16px 0 22px;padding:14px 16px;background:#f0f6fc;border-left:4px solid #2271b1;border-radius:4px}
.kw-active-term-card span{color:#50575e}
.kw-term-create-card{max-width:720px;margin:0 0 24px;padding:16px;border:1px solid #dcdcde;border-radius:6px;background:#fff}
.kw-term-create-card h2{margin-top:0}
#kw-term-form{display:flex;align-items:end;gap:10px;flex-wrap:wrap}
#kw-term-form label{display:block;width:100%}
#kw-term-name{width:180px;max-width:100%}
.kw-terms-table th:nth-child(1){width:22%}
.kw-terms-table th:nth-child(2){width:16%}
.kw-terms-table th:nth-child(3),.kw-terms-table th:nth-child(4){width:18%}




/* v1.8.0: Import / Export */
.kw-transfer-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:20px;max-width:1100px;margin-top:18px}.kw-transfer-card,.kw-transfer-preview{padding:18px;background:#fff;border:1px solid #dcdcde;border-radius:6px}.kw-transfer-card h2,.kw-transfer-preview h2{margin-top:0}.kw-transfer-components{display:grid;gap:8px;margin:14px 0}.kw-transfer-preview{max-width:1100px;margin-top:20px}.kw-import-commit-form{margin-top:18px}.kw-import-commit-form fieldset{margin:0 0 16px;padding:12px;border:1px solid #dcdcde}@media(max-width:800px){.kw-transfer-grid{grid-template-columns:1fr}}
