/**
 * ACS Agenda Manager - Admin Styles
 *
 * @package ACSAgendaManager
 */

/* ==========================================================================
   Row Actions Container
   ========================================================================== */

.row-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    padding-top: 0.5rem;
}

.row-actions span {
    display: inline-block;
}

.acs-no-link {
    color: #6b7280;
    font-style: italic;
    margin-left: 0.4em;
}

/* ==========================================================================
   Admin Table Styles
   ========================================================================== */

input.col-editagenda:not([type='submit']):not([type='search']):not([type='checkbox']):not(
        [type='radio']
    ),
textarea.col-editagenda {
    width: 100%;
    margin: 0;
}

.alert {
    border: 1px solid #ccc;
    padding: 10px;
    margin: 5px 0;
}

.alert-success {
    border-left: 3px solid #46b450;
    background: #ecf7ed;
}

.modified-warning {
    border: 2px solid #ffcc66 !important;
}

/* ==========================================================================
   Dialog Notices
   ========================================================================== */

#acs-dialog-notices {
    margin-bottom: 1rem;
}

#acs-dialog-notices:empty {
    display: none;
}

#acs-dialog-notices .notice {
    margin: 0;
    padding: 0.75rem 1rem;
    border-radius: 6px;
}

/* ==========================================================================
   Modern Admin Form
   ========================================================================== */

.acs-modern-form {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.acs-form-section {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 1.25rem;
}

.acs-form-section-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0 0 1rem 0;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid #e2e8f0;
    font-size: 14px;
    font-weight: 600;
    color: #1e293b;
}

.acs-form-section-title .dashicons {
    color: #2271b1;
    font-size: 18px;
    width: 18px;
    height: 18px;
}

.acs-form-row {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.acs-form-field {
    margin-bottom: 1rem;
    flex: 1;
    min-width: 200px;
}

.acs-form-field:last-child {
    margin-bottom: 0;
}

.acs-form-field-half {
    flex: 1;
    min-width: 200px;
}

.acs-form-label {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    margin-bottom: 0.5rem;
    font-weight: 500;
    font-size: 13px;
    color: #374151;
}

.acs-form-label .dashicons {
    font-size: 14px;
    width: 14px;
    height: 14px;
    color: #6b7280;
}

.acs-required {
    color: #dc2626;
    font-weight: 600;
}

.acs-form-input,
.acs-form-textarea,
.acs-form-select {
    width: 100%;
    padding: 0.625rem 0.875rem;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 14px;
    line-height: 1.5;
    background: #fff;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.acs-form-input:focus,
.acs-form-textarea:focus,
.acs-form-select:focus {
    border-color: #2271b1;
    box-shadow: 0 0 0 2px rgba(34, 113, 177, 0.15);
    outline: none;
}

.acs-form-input::placeholder,
.acs-form-textarea::placeholder {
    color: #9ca3af;
}

.acs-form-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 0.5rem center;
    background-repeat: no-repeat;
    background-size: 1.5em 1.5em;
    padding-right: 2.5rem;
}

.acs-form-hint {
    margin: 0.375rem 0 0 0;
    font-size: 12px;
    color: #6b7280;
}

.acs-field-error {
    margin: 0.4rem 0 0;
    color: #b32d2e;
    font-size: 12px;
    font-weight: 500;
}

.acs-form-advanced {
    border: 1px solid #dbe4ee;
    border-radius: 10px;
    background: #fff;
    overflow: hidden;
}

.acs-form-advanced > summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    cursor: pointer;
    list-style: none;
    background: linear-gradient(180deg, #f8fafc 0%, #eef4fb 100%);
    color: #1e293b;
    font-size: 14px;
    font-weight: 600;
}

.acs-form-advanced > summary::-webkit-details-marker {
    display: none;
}

.acs-form-advanced-toggle {
    transition: transform 0.2s ease;
    color: #64748b;
}

.acs-form-advanced[open] .acs-form-advanced-toggle {
    transform: rotate(180deg);
}

.acs-form-advanced-content {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    padding: 1rem 1.25rem 1.25rem;
}

/* ==========================================================================
   Date Input Wrapper
   ========================================================================== */

.acs-date-input-wrapper {
    display: flex;
    gap: 0.5rem;
    position: relative;
}

.acs-date-input-wrapper .acs-form-input {
    flex: 1;
}

.acs-date-input-wrapper .button {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    white-space: nowrap;
}

.acs-date-input-wrapper .button .dashicons {
    font-size: 16px;
    width: 16px;
    height: 16px;
}

.acs-selected-dates {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-top: 0.5rem;
}

.acs-selected-dates-empty {
    font-size: 12px;
    color: #6b7280;
    font-style: italic;
}

.acs-date-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    border: 1px solid #cbd5e1;
    background: #f8fafc;
    color: #1e293b;
}

.acs-date-chip-label {
    font-size: 12px;
    font-weight: 500;
}

.acs-date-chip-remove {
    border: none;
    background: transparent;
    color: #475569;
    cursor: pointer;
    font-size: 15px;
    line-height: 1;
    padding: 0;
}

.acs-date-chip-remove:hover {
    color: #b32d2e;
}

.acs-date-chip-remove:focus,
.acs-date-chip-remove:focus-visible {
    color: #b32d2e;
    outline: 2px solid #1d4ed8;
    outline-offset: 2px;
}

/* ==========================================================================
   Image Upload
   ========================================================================== */

.acs-image-upload-wrapper {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.acs-image-preview {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 1.5rem;
    background: #fff;
    border: 2px dashed #d1d5db;
    border-radius: 8px;
    min-height: 120px;
    transition: border-color 0.15s ease, background 0.15s ease;
}

.acs-image-preview:hover {
    border-color: #2271b1;
    background: #f0f7ff;
}

.acs-image-preview .dashicons {
    font-size: 32px;
    width: 32px;
    height: 32px;
    color: #9ca3af;
}

.acs-image-preview-text {
    font-size: 13px;
    color: #6b7280;
}

.acs-image-preview.has-image {
    padding: 0.5rem;
    border-style: solid;
    border-color: #d1d5db;
}

.acs-image-preview.has-image img {
    max-width: 100%;
    max-height: 150px;
    border-radius: 4px;
    object-fit: contain;
}

.acs-image-input-group {
    display: flex;
    gap: 0.5rem;
}

.acs-image-input-group .acs-form-input {
    flex: 1;
}

.acs-image-input-group .button .dashicons {
    font-size: 16px;
    width: 16px;
    height: 16px;
    line-height: 1;
}

.acs-remove-image {
    color: #dc2626 !important;
}

.acs-remove-image:hover {
    background: #fee2e2 !important;
    border-color: #dc2626 !important;
}

/* ==========================================================================
   Form Error State
   ========================================================================== */

input.error,
textarea.error,
select.error {
    border-color: var(--acs-danger-color) !important;
    box-shadow: 0 0 2px var(--acs-danger-color);
}

/* ==========================================================================
   jQuery UI Dialog Improvements
   ========================================================================== */

.ui-dialog.ui-widget {
    border-radius: 12px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    border: none;
}

.ui-dialog .ui-dialog-titlebar {
    background: linear-gradient(135deg, #1e3a5f 0%, #2c5282 100%);
    border: none;
    border-radius: 12px 12px 0 0;
    padding: 1rem 1.25rem;
}

.ui-dialog .ui-dialog-title {
    color: #fff;
    font-weight: 600;
    font-size: 16px;
}

.ui-dialog .ui-dialog-titlebar-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 6px;
    width: 32px;
    height: 32px;
    top: 50%;
    right: 1rem;
    margin-top: -16px;
    transition: background 0.15s ease;
}

.ui-dialog .ui-dialog-titlebar-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

.ui-dialog .ui-dialog-titlebar-close .ui-icon {
    background-image: none;
}

.ui-dialog .ui-dialog-titlebar-close::after {
    content: "✕";
    color: #fff;
    font-size: 14px;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.ui-dialog .ui-dialog-content {
    padding: 1.25rem;
    background: #fff;
}

.ui-dialog .ui-dialog-buttonpane {
    background: #f8fafc;
    border-top: 1px solid #e2e8f0;
    padding: 1.25rem;
    border-radius: 0 0 12px 12px;
    min-height: 60px;
    box-sizing: border-box;
}

.ui-dialog .ui-dialog-buttonpane .ui-button {
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-weight: 500;
    font-size: 14px;
    line-height: 1.4;
    margin-left: 0.5rem;
    margin-bottom: 0;
    /* min-height = padding-top + padding-bottom + font-size * line-height */
    min-height: calc(1rem + 14px * 1.4);
}

.ui-dialog .ui-dialog-buttonpane .ui-button-primary,
.ui-dialog .ui-dialog-buttonpane .ui-button:first-child {
    background: #2271b1;
    border-color: #2271b1;
    color: #fff;
}

.ui-dialog .ui-dialog-buttonpane .ui-button-primary:hover,
.ui-dialog .ui-dialog-buttonpane .ui-button:first-child:hover {
    background: #135e96;
    border-color: #135e96;
}

/* ==========================================================================
   Datepicker Container
   ========================================================================== */

#acs-datepicker-container {
    display: none;
}

#acs-datepicker-container.active {
    display: block;
    position: absolute;
    left: 0;
    margin-bottom: 5px;
    padding: 10px;
    background: #fff;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 10000;
}

#acs-datepicker-container.active.is-above {
    bottom: 100%;
    top: auto;
}

#acs-datepicker-container.active.is-below {
    top: calc(100% + 5px);
    bottom: auto;
}

/* Datepicker close button */
.acs-datepicker-close {
    display: block;
    width: 100%;
    margin-top: 10px;
    padding: 10px 16px;
    background: #2271b1;
    color: #fff !important;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
    font-size: 13px;
    text-align: center;
    transition: background 0.2s ease;
}

.acs-datepicker-close:hover {
    background: #135e96;
}

.acs-datepicker-close:focus {
    outline: 2px solid #2271b1;
    outline-offset: 2px;
}

/* ==========================================================================
   jQuery UI Datepicker Fixes
   ========================================================================== */

table.ui-datepicker-calendar {
    border-collapse: separate;
}

.ui-datepicker-calendar td {
    border: 1px solid transparent;
}

#ui-datepicker-div {
    display: none;
}

.ui-datepicker .ui-datepicker-calendar .ui-state-highlight a {
    background: #245da3;
    color: #fff;
}

/* Past dates styling - grayed out and not clickable */
.ui-datepicker td.ui-datepicker-unselectable,
.ui-datepicker td.ui-state-disabled,
.ui-datepicker td.acs-past-date {
    opacity: 0.4;
    pointer-events: none;
}

.ui-datepicker td.ui-datepicker-unselectable span,
.ui-datepicker td.ui-state-disabled span,
.ui-datepicker td.acs-past-date span {
    color: #999;
    text-decoration: line-through;
}

@media (max-width: 782px) {
    .acs-date-input-wrapper {
        flex-direction: column;
        align-items: stretch;
    }

    #acs-datepicker-container.active,
    #acs-datepicker-container.active.is-above,
    #acs-datepicker-container.active.is-below {
        position: static;
        margin-top: 0.6rem;
        margin-bottom: 0;
        width: 100%;
    }

    .ui-datepicker {
        width: 100%;
    }
}
