/* ===== 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 ===== */
.select2-container {
    width: 100% !important;
    box-sizing: border-box;
}

.select2-container--default .select2-selection--multiple .select2-selection__rendered {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
}

.select2-container--default .select2-selection--multiple .select2-search--inline {
    margin: 0;
    padding: 0;
    flex-grow: 1;
}

.select2-container--default .select2-selection--multiple .select2-search__field {
    width: 100% !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;
    }
}