/* components.css: Fields, buttons, alerts, group headers for CentralNic TLD Configuration UI */

/* --- FIELD GROUPS & ROWS --- */
.fields-title {
    display: flex;
    align-items: center;
    font-size: 20px;
    color: #1a5b98;
    border-bottom: 2px solid #eaeff4;
    padding-bottom: 16px;
    margin-bottom: 25px;
    background: #f8fafc;
    padding: 15px 20px;
    border-radius: 6px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.fields-title i {
    margin-right: 12px;
    color: #2e86de;
    font-size: 1.1em;
}

.field-group-header {
    font-size: 17px;
    font-weight: 600;
    color: #2e5b8a;
    margin: 28px 0 16px 0;
    padding: 12px 16px;
    border-bottom: 2px solid #e0e7ee;
    background: #f5f8fb;
    border-radius: 6px;
    border-left: 4px solid #3a7cbb;
    display: flex;
    align-items: center;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.field-group-header i {
    margin-right: 10px;
    color: #4a90e2;
    font-size: 1.1em;
}

.field-row {
    /* Use Bootstrap card styling pattern with custom left border */
    background-color: #ffffff;
    border: 1px solid #dce4ec;
    border-left: 4px solid #3a7cbb;
    border-radius: 4px;
    margin-bottom: 20px;
    padding: 20px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    transition: box-shadow 0.2s ease, border-color 0.2s ease;
    width: 100%;
    box-sizing: border-box;
    /* Allows Bootstrap spacing classes to be applied */
    display: flex;
    flex-direction: column;
}

.field-label {
    font-size: 16px;
    font-weight: 600;
    color: #2d3748;
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding-bottom: 10px;
    margin-bottom: 12px;
    border-bottom: 1px dashed #eee;
}

.field-input {
    margin-top: 12px;
    margin-bottom: 8px;
    width: 100%;
    position: relative;
}

.field-input .form-control {
    width: 100% !important;
    min-width: 100%;
    box-sizing: border-box;
}

.field-help {
    color: #5e6e7d;
    font-size: 14px;
    line-height: 1.5;
    margin-top: 10px;
    padding: 12px 16px;
    background-color: #f5f8fa;
    border-radius: 6px;
    border-left: 3px solid #a8c6df;
}

.required-indicator {
    font-size: 12px;
    padding: 4px 10px;
    border-radius: 12px;
    background-color: #5bc0de;
    color: #fff;
    margin-left: 10px;
    font-weight: normal;
}

/* --- BUTTONS & ACTIONS --- */
.form-actions {
    margin-top: 35px;
    padding: 24px;
    text-align: center;
    background-color: #f8fafb;
    border-radius: 6px;
    border: 1px solid #e1eaf2;
    box-shadow: 0 -2px 3px rgba(0, 0, 0, 0.02);
}

#saveFieldsButton {
    min-width: 180px;
    background-color: #2e86de;
    border-color: #2779bd;
    position: relative;
    overflow: hidden;
    color: #fff;
    font-weight: 500;
    padding: 12px 28px;
    transition: all 0.2s ease;
}

#saveFieldsButton:hover {
    background-color: #1c7cd6;
    border-color: #166dbd;
    box-shadow: 0 4px 8px rgba(46, 134, 222, 0.2);
    transform: translateY(-1px);
}

/* Custom cancel button - compatible with Bootstrap 3.4.1 */
.cnicadmin-cancel-button {
    min-width: 140px;
    margin-left: 12px;
    /* Ensure proper spacing and consistent appearance */
    padding: 10px 16px;
}

.cnicadmin-cancel-button i {
    margin-right: 6px;
}

/* --- ALERTS --- */
.alert {
    border-radius: 6px;
    margin-bottom: 20px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
    padding: 16px 20px;
    font-size: 15px;
    border: none;
}

.alert-success {
    background-color: #ebf8f5;
    color: #0f766e;
    border-left: 4px solid #14b8a6;
}

.alert-danger {
    background-color: #fef2f2;
    color: #b91c1c;
    border-left: 4px solid #ef4444;
}

.alert-info {
    background-color: #eff6ff;
    color: #1e40af;
    border-left: 4px solid #3b82f6;
}

/* Field row animations */
.field-row {
    transform: translateY(0);
    transition: transform 0.3s ease-out, opacity 0.3s ease-out, box-shadow 0.2s ease-out, border-left-color 0.2s ease-out;
    will-change: transform, opacity;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Loading state and transitions */
.field-row.loading {
    opacity: 0.7;
    pointer-events: none;
}

.loading-pulse {
    animation: pulse 1.5s infinite ease-in-out;
}

@keyframes pulse {
    0% {
        opacity: 1;
    }

    50% {
        opacity: 0.6;
    }

    100% {
        opacity: 1;
    }
}

/* Accessibility improvements */
.form-control:focus {
    border-color: #4a90e2;
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.2);
    outline: none;
}

[role="button"]:focus,
button:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.4);
}

/* --- SELECTIZE DROPDOWN STYLING --- */

/* Main container */
.selectize-control {
    position: relative;
    width: 100%;
    font-family: inherit;
    z-index: 1;
}

/* Input field styling */
.selectize-input {
    background: #ffffff;
    border: 1px solid #cbd5e1;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    width: 100%;
    overflow: hidden;
    position: relative;
    z-index: 1;
    box-sizing: border-box;
    box-shadow: none;
    border-radius: 3px;
    transition: all 0.25s ease;
    height: 48px;
    min-height: 48px;
    border-left: 0;
}

/* Input focus and dropdown active state */
.selectize-input.focus {
    border-color: #1a5b98;
    box-shadow: 0 0 0 2px rgba(26, 91, 152, 0.15);
    z-index: 3;
}

/* Adjust focus within input group */
.input-group.focused .selectize-input.focus {
    border-color: #1a5b98;
    z-index: 3;
}

.selectize-input.dropdown-active {
    border-radius: 3px 3px 0 0;
    border-color: #1a5b98;
}

/* Fix input sizing */
.selectize-input>input {
    min-height: 0;
    height: auto;
    margin: 0;
    padding: 0;
    max-width: 100%;
}

/* Dropdown styling */
.selectize-dropdown {
    position: absolute !important;
    z-index: 1060;
    background: #ffffff;
    margin: -1px 0 0 0;
    border: 1px solid #1a5b98;
    border-top: 0;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    border-radius: 0 0 3px 3px;
    animation: selectizeDropdown 0.2s ease-out;
    transform-origin: top center;
    overflow: hidden;
    box-sizing: border-box !important;
}

@keyframes selectizeDropdown {
    from {
        opacity: 0;
        transform: translateY(-8px) scale(0.98);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Dropdown content */
.selectize-dropdown-content {
    overflow-y: auto;
    max-height: 280px;
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 #f8fafc;
}

/* Scrollbar styling for WebKit browsers */
.selectize-dropdown-content::-webkit-scrollbar {
    width: 6px;
}

.selectize-dropdown-content::-webkit-scrollbar-track {
    background: #f8fafc;
}

.selectize-dropdown-content::-webkit-scrollbar-thumb {
    background-color: #cbd5e1;
    border-radius: 3px;
}

/* Option styling */
.selectize-dropdown .option {
    padding: 12px 16px;
    cursor: pointer;
    font-size: 14px;
    border-bottom: 1px solid #f0f4f8;
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
    display: flex;
    align-items: center;
    line-height: 1.4;
    width: 100%;
    box-sizing: border-box;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    height: auto;
    min-height: 42px;
}

/* Option hover state */
.selectize-dropdown .option:hover:not(.active) {
    background-color: #f0f7ff;
    border-left: 3px solid #66afe9;
}

/* Active option */
.selectize-dropdown .option.active {
    background-color: #1a5b98;
    color: white;
    border-left: 3px solid #1a5b98;
    font-weight: 500;
}

.selectize-control.single .selectize-input.input-active {
    display: flex;
}

/* Improve highlighting in dropdown */
.selectize-dropdown .option .highlight {
    background-color: rgba(255, 230, 0, 0.4);
    color: inherit;
    font-weight: 600;
    border-radius: 2px;
    padding: 0 1px;
    box-shadow: 0 0 0 1px rgba(255, 204, 0, 0.3);
}

/* Active option with highlight */
.selectize-dropdown .option.active .highlight {
    background-color: rgba(255, 255, 255, 0.3);
    color: white;
    font-weight: 600;
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.5);
}

/* Selected item styling */
.selectize-input .item {
    color: #1a5b98;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: calc(100% - 20px);
}

/* Dropdown arrow styling */
.selectize-control.single .selectize-input:after {
    content: '';
    display: block;
    position: absolute;
    top: 50%;
    right: 15px;
    margin-top: -3px;
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 6px 5px 0 5px;
    border-color: #555 transparent transparent transparent;
    transition: transform 0.3s ease;
}

/* Dropdown arrow when dropdown is open */
.selectize-control.single .selectize-input.dropdown-active:after {
    transform: rotate(180deg);
    margin-top: -2px;
}

/* Placeholder styling */
.selectize-input>input::placeholder {
    color: #999;
    font-style: italic;
    opacity: 0.7;
}

/* Loading indicator */
.selectize-input.loading {
    cursor: progress;
}

.selectize-input.loading:after {
    content: '';
    position: absolute;
    right: 35px;
    top: 50%;
    margin-top: -8px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid rgba(26, 91, 152, 0.2);
    border-top-color: #1a5b98;
    border-right-color: #1a5b98;
    animation: selectize-spinner 0.7s linear infinite;
}

@keyframes selectize-spinner {
    to {
        transform: rotate(360deg);
    }
}

/* No results message styling */
.selectize-dropdown .no-results {
    padding: 12px 16px;
    color: #64748b;
    font-style: italic;
    text-align: center;
    border-bottom: none;
    background-color: #f8fafc;
    font-size: 14px;
}

/* --- BOOTSTRAP COMPATIBILITY FIXES --- */

/* Fix for Input Group positioning */
.input-group .selectize-control {
    display: table-cell;
    width: 100%;
    vertical-align: middle;
}

/* Fix for Bootstrap table-cell layout */
.input-group .selectize-control .selectize-input {
    display: flex;
    border-radius: 0;
}

/* Constrain dropdown width to its parent container */
.input-group .selectize-control .selectize-dropdown {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    position: absolute !important;
    left: 0 !important;
    right: auto !important;
}

/* Input Group Addon styling fixes */
.input-group-addon+.selectize-control .selectize-input {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
}

.input-group .selectize-control+.input-group-addon,
.input-group .selectize-control+.input-group-btn {
    border-left: 0;
}

.input-group .selectize-control:first-child .selectize-input {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}

.input-group .selectize-control:not(:first-child) .selectize-input {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
}

.input-group .selectize-control:not(:last-child) .selectize-input {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}

/* Fix for input group styling - specifically for the TLD lookup form */
.input-group-addon:first-child {
    border-right: 0;
}

/* Special case handler for the selectize between input group elements */
.selectize-between-elements .selectize-input {
    border-radius: 0;
    box-shadow: none !important;
}

.selectize-between-elements.selectize-focus .selectize-input {
    position: relative;
    z-index: 4;
    border-color: #1a5b98;
}

/* TLD lookup form specific fixes */
#lookupFieldsForm .input-group {
    box-shadow: 0 1px 5px rgba(0, 0, 0, 0.05);
    border-radius: 4px;
    overflow: visible;
    z-index: 0;
    position: relative;
    display: table;
    table-layout: fixed;
}

#lookupFieldsForm .selectize-control {
    display: table-cell;
    float: none;
    margin: 0;
    padding: 0;
    vertical-align: top;
    width: 100%;
    position: relative;
}

#lookupFieldsForm .selectize-dropdown {
    width: 100% !important;
    max-width: 100% !important;
    left: 0 !important;
    right: auto !important;
    position: absolute !important;
    box-sizing: border-box;
}

#lookupFieldsForm .input-group-addon {
    width: 50px;
    text-align: center;
    vertical-align: middle;
    width: 1%;
    white-space: nowrap;
}

#lookupFieldsForm .input-group-btn {
    width: 1%;
    white-space: nowrap;
    vertical-align: middle;
}

#lookupFieldsForm .input-group-btn .btn {
    height: 48px;
    margin: 0;
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
}

#lookupFieldsForm .selectize-input input {
    min-height: 0;
    height: auto;
    box-shadow: none !important;
}

#lookupFieldsForm .form-control {
    box-shadow: none !important;
}

#lookupFieldsForm .input-group-addon i {
    font-size: 20px;
}

/* --- RESPONSIVE ADJUSTMENTS --- */

@media screen and (max-width: 767px) {

    /* Increase tap target sizes on mobile */
    .selectize-dropdown .option {
        padding: 14px 16px;
        font-size: 15px;
        min-height: 46px;
    }

    .selectize-input {
        height: 52px;
        padding: 14px 16px;
    }

    /* Ensure dropdown doesn't get cut off on small screens */
    .selectize-dropdown {
        max-width: calc(100vw - 30px);
        position: fixed !important;
        top: auto !important;
        border-radius: 6px;
        border: 1px solid #1a5b98;
        margin-top: 0;
        box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
    }

    /* Improve height on mobile to show more options */
    .selectize-dropdown-content {
        max-height: 320px;
    }

    /* Ensure button and form alignment on mobile */
    #lookupFieldsForm .input-group {
        display: flex;
        flex-wrap: nowrap;
    }

    #lookupFieldsForm .input-group-addon {
        display: flex;
        align-items: center;
        justify-content: center;
        min-width: 45px;
        width: auto;
        padding: 14px 16px;
    }

    #lookupFieldsForm .selectize-control {
        flex: 1;
        width: auto;
        display: flex;
    }

    #lookupFieldsForm .input-group-btn {
        width: auto;
    }
}

/* --- PRINT MEDIA QUERIES --- */

@media print {
    .selectize-control {
        border: 1px solid #ddd;
        print-color-adjust: exact;
        -webkit-print-color-adjust: exact;
    }

    .selectize-input {
        border: none !important;
        box-shadow: none !important;
    }

    .selectize-dropdown,
    .selectize-dropdown-content {
        display: none !important;
    }

    .selectize-input .item {
        background-color: #f8f8f8 !important;
        color: #000 !important;
        border: 1px solid #ccc;
    }
}

/* --- DOCUMENTATION BUTTON --- */
.cnic-documentation-btn {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    text-decoration: none;
    font-size: 13px;
    transition: all 0.2s ease;
}
.cnic-documentation-btn:hover {
    background: rgba(255, 255, 255, 0.25);
    color: #fff;
}