/**
 * Elementor Certificate Search Widget Styles
 *
 * Professional, modern styling for the certificate search widget.
 *
 * @package Namaa_Certificate_Coding_System
 */

/* ==================== CSS VARIABLES ==================== */
.ncs-widget {
    --ncs-primary: #1a56db;
    --ncs-primary-light: #3b82f6;
    --ncs-primary-dark: #1e40af;
    --ncs-success: #10b981;
    --ncs-success-light: #d1fae5;
    --ncs-error: #ef4444;
    --ncs-error-light: #fee2e2;
    --ncs-warning: #f59e0b;
    --ncs-warning-light: #fef3c7;
    --ncs-bg: #ffffff;
    --ncs-input-bg: #f9fafb;
    --ncs-text: #1f2937;
    --ncs-muted: #6b7280;
    --ncs-border: #e5e7eb;
    --ncs-radius: 16px;
    --ncs-shadow: 0 4px 24px rgba(0, 0, 0, 0.1);
    --ncs-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);

    position: relative;
    background: var(--ncs-bg);
    border: 1px solid var(--ncs-border);
    border-radius: var(--ncs-radius);
    padding: 32px;
    max-width: 600px;
    margin: 0 auto;
    font-family: 'Cairo', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    color: var(--ncs-text);
    box-sizing: border-box;
}

.ncs-widget * {
    box-sizing: border-box;
}

/* ==================== HEADER ==================== */
.ncs-widget-header {
    text-align: center;
    margin-bottom: 28px;
}

.ncs-widget-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    background: linear-gradient(135deg, var(--ncs-primary), var(--ncs-primary-light));
    border-radius: 16px;
    margin-bottom: 16px;
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(26, 86, 219, 0.3);
}

.ncs-widget-icon svg {
    width: 28px;
    height: 28px;
}

.ncs-widget-title {
    margin: 0 0 8px;
    color: var(--ncs-text);
    line-height: 1.3;
}

.ncs-widget-subtitle {
    margin: 0;
    color: var(--ncs-muted);
    line-height: 1.6;
}

/* ==================== FORM ==================== */
.ncs-widget-form {
    margin-bottom: 24px;
}

.ncs-widget-input-group {
    display: flex;
    align-items: stretch;
    background: var(--ncs-input-bg);
    border: 2px solid var(--ncs-border);
    border-radius: 12px;
    transition: var(--ncs-transition);
    overflow: hidden;
}

.ncs-widget-input-group:focus-within {
    border-color: var(--ncs-primary);
    background: #ffffff;
    box-shadow: 0 0 0 4px rgba(26, 86, 219, 0.1);
}

.ncs-widget-input-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 12px;
    color: var(--ncs-muted);
    flex-shrink: 0;
}

.ncs-widget-input-icon svg {
    width: 20px;
    height: 20px;
}

.ncs-widget-input {
    flex: 1;
    border: none;
    background: transparent;
    padding: 14px 8px;
    color: var(--ncs-text);
    outline: none;
    min-width: 0;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.ncs-widget-input::placeholder {
    color: var(--ncs-muted);
    text-transform: none;
    letter-spacing: normal;
    opacity: 0.7;
}

.ncs-widget-search-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 14px 24px;
    background: linear-gradient(135deg, var(--ncs-primary), var(--ncs-primary-light));
    color: #ffffff;
    border: none;
    cursor: pointer;
    font-family: inherit;
    font-weight: 600;
    font-size: 14px;
    white-space: nowrap;
    transition: var(--ncs-transition);
    flex-shrink: 0;
}

.ncs-widget-search-btn:hover {
    background: linear-gradient(135deg, var(--ncs-primary-dark), var(--ncs-primary));
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(26, 86, 219, 0.3);
}

.ncs-widget-search-btn:active {
    transform: translateY(0);
}

.ncs-widget-search-btn.is-loading .ncs-widget-btn-text {
    display: none;
}

.ncs-widget-search-btn.is-loading .ncs-widget-btn-loading {
    display: inline-flex;
}

.ncs-widget-spinner {
    width: 20px;
    height: 20px;
    animation: ncsWidgetSpin 1s linear infinite;
}

.ncs-widget-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 20px;
}

.ncs-widget-loading p {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #ffffff;
    opacity: 0.95;
}

@keyframes ncsWidgetSpin {
    0% {
        transform: rotate(0deg);
        stroke-dashoffset: 31.4;
    }
    50% {
        stroke-dashoffset: 0;
    }
    100% {
        transform: rotate(360deg);
        stroke-dashoffset: -31.4;
    }
}

/* ==================== FORMAT HINT ==================== */
.ncs-widget-format-hint {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 12px;
    padding: 10px 14px;
    background: #f0f9ff;
    border-radius: 8px;
    color: var(--ncs-primary);
    font-size: 12px;
    line-height: 1.5;
}

.ncs-widget-format-hint svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

/* ==================== RESULTS ==================== */
.ncs-widget-results {
    animation: ncsWidgetFadeIn 0.4s ease-out;
}

@keyframes ncsWidgetFadeIn {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Result Card */
.ncs-widget-result-card {
    border: 1px solid var(--ncs-border);
    border-radius: 12px;
    overflow: hidden;
}

/* Result Header */
.ncs-widget-result-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    color: #ffffff;
}

.ncs-widget-result-header.is-valid {
    background: linear-gradient(135deg, var(--ncs-success), #059669);
}

.ncs-widget-result-header.is-invalid {
    background: linear-gradient(135deg, var(--ncs-error), #dc2626);
}

.ncs-widget-result-header.is-revoked {
    background: linear-gradient(135deg, var(--ncs-warning), #d97706);
}

.ncs-widget-result-header.is-pending {
    background: linear-gradient(135deg, #8b5cf6, #7c3aed);
}

/* BEM-style classes (used by JS) */
.ncs-widget-result-header--valid {
    background: linear-gradient(135deg, var(--ncs-success), #059669);
    color: #ffffff;
}

.ncs-widget-result-header--error {
    background: linear-gradient(135deg, var(--ncs-error), #dc2626);
    color: #ffffff;
}

.ncs-widget-result-header--revoked {
    background: linear-gradient(135deg, var(--ncs-warning), #d97706);
    color: #ffffff;
}

.ncs-widget-result-header--pending {
    background: linear-gradient(135deg, #8b5cf6, #7c3aed);
    color: #ffffff;
}

.ncs-widget-result-header--loading {
    background: linear-gradient(135deg, var(--ncs-primary), #2563eb);
    color: #ffffff;
}

/* Inline spinner inside result card header */
.ncs-widget-spinner--inline {
    width: 24px;
    height: 24px;
    color: #ffffff;
    animation: ncsWidgetSpinSvg 1s linear infinite;
}

@keyframes ncsWidgetSpinSvg {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

.ncs-widget-spinner--inline circle {
    stroke: currentColor;
    stroke-width: 3;
    stroke-linecap: round;
    stroke-dasharray: 31.4;
    stroke-dashoffset: 31.4;
    animation: ncsWidgetSpinDash 0.8s ease-in-out infinite;
}

@keyframes ncsWidgetSpinDash {
    0% {
        stroke-dashoffset: 31.4;
    }
    50% {
        stroke-dashoffset: 0;
    }
    100% {
        stroke-dashoffset: -31.4;
    }
}

/* Result icon container (matches error/valid/pending cards) */
.ncs-widget-result-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    flex-shrink: 0;
}

.ncs-widget-result-title {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: inherit;
    line-height: 1.4;
}

.ncs-widget-result-status-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    flex-shrink: 0;
}

.ncs-widget-result-status-icon svg {
    width: 24px;
    height: 24px;
}

.ncs-widget-result-status-text {
    flex: 1;
}

.ncs-widget-result-status-title {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
}

.ncs-widget-result-status-msg {
    margin: 4px 0 0;
    font-size: 13px;
    opacity: 0.9;
}

/* Result Body */
.ncs-widget-result-body {
    padding: 20px;
}

.ncs-widget-result-grid {
    display: grid;
    gap: 16px;
}

.ncs-widget-result-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.ncs-widget-result-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--ncs-muted);
}

.ncs-widget-result-value {
    font-size: 14px;
    font-weight: 500;
    color: var(--ncs-text);
    word-break: break-word;
}

.ncs-widget-result-code {
    font-family: 'Courier New', Courier, monospace;
    font-size: 18px;
    font-weight: 700;
    letter-spacing: 2px;
    color: var(--ncs-primary);
    background: var(--ncs-input-bg);
    padding: 8px 16px;
    border-radius: 8px;
    text-align: center;
    display: inline-block;
    width: 100%;
}

/* Result Photo */
.ncs-widget-result-photo {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--ncs-input-bg);
    border-radius: 10px;
}

.ncs-widget-result-photo img {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--ncs-border);
    flex-shrink: 0;
}

.ncs-widget-result-photo-info {
    flex: 1;
    min-width: 0;
}

.ncs-widget-result-photo-name {
    font-weight: 600;
    color: var(--ncs-text);
    margin: 0 0 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ncs-widget-result-photo-label {
    font-size: 12px;
    color: var(--ncs-muted);
    margin: 0;
}

/* Result Divider */
.ncs-widget-result-divider {
    height: 1px;
    background: var(--ncs-border);
    margin: 4px 0;
}

/* Result Footer */
.ncs-widget-result-footer {
    padding: 16px 20px;
    background: var(--ncs-input-bg);
    border-top: 1px solid var(--ncs-border);
    text-align: center;
}

.ncs-widget-view-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 28px;
    background: linear-gradient(135deg, var(--ncs-primary), var(--ncs-primary-light));
    color: #ffffff;
    text-decoration: none;
    border-radius: 10px;
    font-weight: 600;
    font-size: 14px;
    transition: var(--ncs-transition);
}

.ncs-widget-view-btn:hover {
    background: linear-gradient(135deg, var(--ncs-primary-dark), var(--ncs-primary));
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(26, 86, 219, 0.3);
    color: #ffffff;
    text-decoration: none;
}

.ncs-widget-view-btn svg {
    width: 18px;
    height: 18px;
}

/* Verified Badge */
.ncs-widget-verified-badge {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin-top: 12px;
    font-size: 12px;
    color: var(--ncs-success);
    font-weight: 500;
}

.ncs-widget-verified-badge svg {
    width: 14px;
    height: 14px;
}

/* ==================== ERROR STATE ==================== */
.ncs-widget-error-msg {
    text-align: center;
    padding: 24px 20px;
}

.ncs-widget-error-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    background: var(--ncs-error-light);
    border-radius: 50%;
    margin-bottom: 12px;
    color: var(--ncs-error);
}

.ncs-widget-error-icon svg {
    width: 24px;
    height: 24px;
}

.ncs-widget-error-title {
    margin: 0 0 8px;
    font-size: 16px;
    font-weight: 600;
    color: var(--ncs-text);
}

.ncs-widget-error-text {
    margin: 0;
    font-size: 14px;
    color: var(--ncs-muted);
    line-height: 1.6;
}

/* ==================== RESPONSIVE ==================== */
@media (max-width: 640px) {
    .ncs-widget {
        padding: 24px 20px;
        border-radius: 12px;
    }

    .ncs-widget-input-group {
        flex-direction: column;
    }

    .ncs-widget-input {
        padding: 12px 16px;
    }

    .ncs-widget-search-btn {
        padding: 14px;
        border-radius: 0 0 10px 10px;
    }

    .ncs-widget-input-icon {
        display: none;
    }

    .ncs-widget-result-header {
        padding: 14px 16px;
    }

    .ncs-widget-result-body {
        padding: 16px;
    }

    .ncs-widget-result-footer {
        padding: 14px 16px;
    }

    .ncs-widget-result-code {
        font-size: 16px;
    }
}

/* ==================== RTL SUPPORT ==================== */
.ncs-widget-rtl {
    direction: rtl;
    text-align: right;
}

.ncs-widget-rtl .ncs-widget-view-btn svg {
    transform: scaleX(-1);
}

/* ==================== ANIMATIONS ==================== */
.ncs-widget-result-card {
    animation: ncsWidgetSlideUp 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes ncsWidgetSlideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.ncs-widget-result-item {
    animation: ncsWidgetItemFade 0.4s ease-out both;
}

.ncs-widget-result-item:nth-child(1) { animation-delay: 0.05s; }
.ncs-widget-result-item:nth-child(2) { animation-delay: 0.1s; }
.ncs-widget-result-item:nth-child(3) { animation-delay: 0.15s; }
.ncs-widget-result-item:nth-child(4) { animation-delay: 0.2s; }
.ncs-widget-result-item:nth-child(5) { animation-delay: 0.25s; }
.ncs-widget-result-item:nth-child(6) { animation-delay: 0.3s; }
.ncs-widget-result-item:nth-child(7) { animation-delay: 0.35s; }
.ncs-widget-result-item:nth-child(8) { animation-delay: 0.4s; }

@keyframes ncsWidgetItemFade {
    from {
        opacity: 0;
        transform: translateX(-8px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* ==================== STATUS BADGE ==================== */
.ncs-widget-status-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.ncs-widget-status-badge.is-issued {
    background: var(--ncs-success-light);
    color: var(--ncs-success);
}

.ncs-widget-status-badge.is-revoked {
    background: var(--ncs-error-light);
    color: var(--ncs-error);
}

.ncs-widget-status-badge.is-pending {
    background: var(--ncs-warning-light);
    color: var(--ncs-warning);
}

.ncs-widget-status-badge svg {
    width: 12px;
    height: 12px;
}

/* ==================== CLEAR BUTTON ==================== */
.ncs-widget-clear-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: transparent;
    border: none;
    border-radius: 6px;
    color: var(--ncs-muted);
    cursor: pointer;
    transition: var(--ncs-transition);
    flex-shrink: 0;
    margin-right: 4px;
}

.ncs-widget-clear-btn:hover {
    background: var(--ncs-border);
    color: var(--ncs-text);
}

.ncs-widget-clear-btn svg {
    width: 16px;
    height: 16px;
}

.ncs-widget-clear-btn.hidden {
    display: none;
}

/* ==================== BANNER WIDGET ==================== */
.ncs-banner {
    position: relative;
    display: flex;
    align-items: center;
    min-height: 300px;
    background-color: #1a1a2e;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    border-radius: 20px;
    overflow: hidden;
}

.ncs-banner-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 1;
}

/* Left side image */
.ncs-banner-left-image {
    position: relative;
    z-index: 2;
    flex-shrink: 0;
    width: 35%;
    max-height: 100%;
    display: flex;
    align-items: flex-end;
}

.ncs-banner-left-image img {
    width: 100%;
    max-height: 100%;
    object-fit: cover;
    display: block;
}

/* Default gradient when no left image */
.ncs-banner-left-gradient {
    position: relative;
    z-index: 2;
    flex-shrink: 0;
    width: 35%;
    min-height: 100%;
    background: linear-gradient(180deg, #16213e 0%, #0f3460 40%, #1a56db 100%);
    opacity: 0.8;
}

/* RTL: Arabic - image on left, content on right */
[dir="rtl"] .ncs-banner {
    flex-direction: row-reverse;
}

[dir="rtl"] .ncs-banner-content {
    text-align: right;
}

[dir="rtl"] .ncs-banner-search-form {
    margin-left: auto;
    margin-right: 0;
}

[dir="rtl"] .ncs-banner-content {
    /* Frame image opening to the left - normal orientation */
    background-image: none;
    background-repeat: no-repeat;
    background-position: center right;
    background-size: 130%;
}

/* LTR: English - image on right, content on left, flip frame */
[dir="ltr"] .ncs-banner {
    flex-direction: row;
}

[dir="ltr"] .ncs-banner-content {
    text-align: left;
}

[dir="ltr"] .ncs-banner-search-form {
    margin-right: auto;
    margin-left: 0;
}

[dir="ltr"] .ncs-banner-content {
    /* Frame image flipped horizontally */
    background-repeat: no-repeat;
    background-position: center left;
    background-size: 130%;
}

.ncs-banner-content {
    position: relative;
    z-index: 3;
    flex: 1;
    padding: 130px 80px 130px 120px;
}

[dir="ltr"] .ncs-banner-content {
    padding: 130px 120px 130px 80px;
}

.ncs-banner-title {
    font-size: 32px;
    font-weight: 700;
    color: #ffffff;
    margin: 0 0 25px 0;
    line-height: 1.3;
}

.ncs-banner-search-form {
    max-width: 500px;
}

.ncs-banner-input-group {
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 12px;
    padding: 6px 12px;
    gap: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.ncs-banner-input-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #666666;
    flex-shrink: 0;
}

.ncs-banner-input-icon svg {
    width: 20px;
    height: 20px;
}

.ncs-banner-input {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    font-size: 16px;
    color: #333333;
    padding: 12px 8px;
    min-width: 0;
}

.ncs-banner-input::placeholder {
    color: #999999;
}

.ncs-banner-search-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px 24px;
    background: linear-gradient(135deg, #1a56db, #1e40af);
    color: #ffffff;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
    flex-shrink: 0;
}

.ncs-banner-search-btn:hover {
    background: linear-gradient(135deg, #1e40af, #1e3a8a);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(26, 86, 219, 0.4);
}

.ncs-banner-search-btn:active {
    transform: translateY(0);
}

.ncs-banner-search-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.ncs-banner-btn-loading {
    display: inline-flex;
    align-items: center;
}

.ncs-banner-results {
    position: relative;
    z-index: 3;
    width: 100%;
    margin-top: 20px;
}

.ncs-banner-results .ncs-widget-result-card {
    max-width: 500px;
    margin: 0 auto;
}

/* Banner Responsive */
@media (max-width: 1024px) {
    /* Tablet: reduce frame padding so image still wraps content nicely */
    .ncs-banner-content {
        padding: 100px 60px 100px 90px;
    }

    [dir="ltr"] .ncs-banner-content {
        padding: 100px 90px 100px 60px;
    }

    .ncs-banner-title {
        font-size: 28px;
        margin-bottom: 20px;
    }
}

@media (max-width: 768px) {
    .ncs-banner {
        min-height: 250px;
        border-radius: 16px;
    }

    .ncs-banner-left-image,
    .ncs-banner-left-gradient {
        display: none;
    }

    /* Mobile: replace frame background with a clean CSS decorative border */
    .ncs-banner-content {
        background-image: none !important;
        padding: 35px 25px;
        text-align: center;
        border: 2px solid rgba(255, 255, 255, 0.15);
        border-radius: 16px;
        background: rgba(255, 255, 255, 0.05);
        backdrop-filter: blur(4px);
        -webkit-backdrop-filter: blur(4px);
    }

    .ncs-banner-title {
        font-size: 24px;
        margin-bottom: 20px;
        text-align: center !important;
    }

    .ncs-banner-search-form {
        margin: 0 auto;
        max-width: 100%;
    }

    .ncs-banner-input-group {
        padding: 5px 10px;
    }

    .ncs-banner-search-btn {
        padding: 10px 18px;
        font-size: 14px;
    }

    .ncs-banner-results {
        margin-top: 15px;
    }
}

@media (max-width: 480px) {
    .ncs-banner {
        min-height: 200px;
        border-radius: 12px;
    }

    .ncs-banner-content {
        padding: 25px 16px;
        border-width: 1.5px;
        border-radius: 12px;
    }

    .ncs-banner-title {
        font-size: 20px;
        margin-bottom: 15px;
    }

    /* Hide search icon on small screens */
    .ncs-banner-input-icon {
        display: none;
    }

    /* Remove white background on input group for cleaner look */
    .ncs-banner-input-group {
        flex-direction: column;
        padding: 8px;
        background: transparent;
        box-shadow: none;
    }

    .ncs-banner-input {
        width: 100%;
        text-align: center;
        padding: 10px;
        background: rgba(255, 255, 255, 0.95);
        border-radius: 8px;
        margin-bottom: 8px;
    }

    .ncs-banner-search-btn {
        width: 100%;
        padding: 12px;
    }
}
