/**
 * DPDPA Search Styles
 * Pure CSS - No External Dependencies
 * Author: Dr. Prashant Mali
 * Website: www.dpdpa.com
 */

/* ============================================
   CSS Variables for easy customization
   ============================================ */
:root {
    --dpdpa-primary: #00509e;
    --dpdpa-primary-dark: #003d7a;
    --dpdpa-primary-light: #e3f2fd;
    --dpdpa-accent: #ff6b35;
    --dpdpa-success: #28a745;
    --dpdpa-danger: #dc3545;
    --dpdpa-warning: #ffc107;
    --dpdpa-text: #333333;
    --dpdpa-text-light: #666666;
    --dpdpa-text-muted: #999999;
    --dpdpa-bg: #ffffff;
    --dpdpa-bg-light: #f8f9fa;
    --dpdpa-border: #e0e0e0;
    --dpdpa-shadow: rgba(0, 0, 0, 0.15);
    --dpdpa-overlay: rgba(0, 0, 0, 0.6);
    --dpdpa-radius: 12px;
    --dpdpa-radius-sm: 8px;
    --dpdpa-transition: 0.3s ease;
}

/* ============================================
   Floating Search Button
   ============================================ */
#dpdpa-search-container {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    font-size: 16px;
    line-height: 1.5;
}

.dpdpa-search-btn {
    position: fixed;
    top: 80px;
    right: 20px;
    z-index: 9998;
    width: 50px;
    height: 50px;
    border: none;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--dpdpa-primary) 0%, var(--dpdpa-primary-dark) 100%);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px var(--dpdpa-shadow);
    transition: all var(--dpdpa-transition);
}

.dpdpa-search-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(0, 80, 158, 0.4);
}

.dpdpa-search-btn:active {
    transform: scale(0.95);
}

.dpdpa-search-btn.hidden {
    opacity: 0;
    pointer-events: none;
    transform: scale(0.5);
}

.dpdpa-search-btn .search-icon {
    color: white;
}

/* ============================================
   Search Modal Overlay
   ============================================ */
.dpdpa-search-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9999;
    background: var(--dpdpa-overlay);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 10vh 20px 20px;
    opacity: 0;
    visibility: hidden;
    transition: all var(--dpdpa-transition);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.dpdpa-search-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* ============================================
   Search Modal
   ============================================ */
.dpdpa-search-modal {
    width: 100%;
    max-width: 640px;
    background: var(--dpdpa-bg);
    border-radius: var(--dpdpa-radius);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    overflow: hidden;
    transform: translateY(-20px) scale(0.95);
    transition: all var(--dpdpa-transition);
    max-height: 80vh;
    display: flex;
    flex-direction: column;
}

.dpdpa-search-overlay.active .dpdpa-search-modal {
    transform: translateY(0) scale(1);
}

/* ============================================
   Search Header
   ============================================ */
.dpdpa-search-header {
    display: flex;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--dpdpa-border);
    background: var(--dpdpa-bg-light);
}

.dpdpa-search-input-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--dpdpa-bg);
    border: 2px solid var(--dpdpa-border);
    border-radius: var(--dpdpa-radius-sm);
    padding: 0 16px;
    transition: border-color var(--dpdpa-transition);
}

.dpdpa-search-input-wrapper:focus-within {
    border-color: var(--dpdpa-primary);
    box-shadow: 0 0 0 3px var(--dpdpa-primary-light);
}

.search-input-icon {
    flex-shrink: 0;
    color: var(--dpdpa-text-muted);
}

.dpdpa-search-input {
    flex: 1;
    border: none;
    outline: none;
    padding: 14px 0;
    font-size: 16px;
    font-family: inherit;
    background: transparent;
    color: var(--dpdpa-text);
}

.dpdpa-search-input::placeholder {
    color: var(--dpdpa-text-muted);
}

.dpdpa-search-shortcut {
    flex-shrink: 0;
    padding: 4px 8px;
    background: var(--dpdpa-bg-light);
    border: 1px solid var(--dpdpa-border);
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    color: var(--dpdpa-text-muted);
    text-transform: uppercase;
}

.dpdpa-search-close {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    margin-left: 12px;
    border: none;
    background: transparent;
    color: var(--dpdpa-text-muted);
    cursor: pointer;
    border-radius: var(--dpdpa-radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--dpdpa-transition);
}

.dpdpa-search-close:hover {
    background: var(--dpdpa-bg);
    color: var(--dpdpa-text);
}

/* ============================================
   Search Results Container
   ============================================ */
.dpdpa-search-results {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    min-height: 200px;
    max-height: 400px;
}

/* ============================================
   Default State (Tips)
   ============================================ */
.dpdpa-search-default {
    padding: 20px;
}

.dpdpa-search-tips h4 {
    margin: 0 0 16px 0;
    font-size: 14px;
    font-weight: 600;
    color: var(--dpdpa-text-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.tip-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.tip-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: var(--dpdpa-bg-light);
    border-radius: var(--dpdpa-radius-sm);
}

.tip-item code {
    padding: 4px 8px;
    background: var(--dpdpa-primary-light);
    color: var(--dpdpa-primary);
    border-radius: 4px;
    font-size: 13px;
    font-weight: 600;
    font-family: 'Consolas', 'Monaco', monospace;
}

.tip-item span {
    font-size: 13px;
    color: var(--dpdpa-text-light);
}

.dpdpa-search-stats {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid var(--dpdpa-border);
    color: var(--dpdpa-text-muted);
    font-size: 13px;
}

.dpdpa-search-stats .dot {
    font-size: 8px;
}

/* ============================================
   Results List
   ============================================ */
.dpdpa-search-results-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.results-header {
    font-size: 12px;
    font-weight: 600;
    color: var(--dpdpa-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 0 8px 8px;
    border-bottom: 1px solid var(--dpdpa-border);
    margin-bottom: 8px;
}

.result-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    background: var(--dpdpa-bg);
    border: 1px solid var(--dpdpa-border);
    border-radius: var(--dpdpa-radius-sm);
    text-decoration: none;
    color: var(--dpdpa-text);
    transition: all var(--dpdpa-transition);
    cursor: pointer;
}

.result-item:hover,
.result-item.selected {
    border-color: var(--dpdpa-primary);
    background: var(--dpdpa-primary-light);
    transform: translateX(4px);
}

.result-icon {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border-radius: var(--dpdpa-radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 700;
    color: white;
}

.result-icon.section-icon {
    background: linear-gradient(135deg, var(--dpdpa-primary) 0%, var(--dpdpa-primary-dark) 100%);
}

.result-icon.rule-icon {
    background: linear-gradient(135deg, var(--dpdpa-accent) 0%, #e55a2b 100%);
}

.result-icon.schedule-icon {
    background: linear-gradient(135deg, var(--dpdpa-success) 0%, #1e7e34 100%);
}

.result-content {
    flex: 1;
    min-width: 0;
}

.result-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--dpdpa-text);
    margin-bottom: 2px;
}

.result-subtitle {
    font-size: 14px;
    color: var(--dpdpa-text-light);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 4px;
}

.result-subtitle mark {
    background: #fff59d;
    color: inherit;
    padding: 0 2px;
    border-radius: 2px;
}

.result-meta {
    font-size: 12px;
    color: var(--dpdpa-text-muted);
}

.result-arrow {
    flex-shrink: 0;
    color: var(--dpdpa-text-muted);
    opacity: 0;
    transform: translateX(-5px);
    transition: all var(--dpdpa-transition);
}

.result-item:hover .result-arrow,
.result-item.selected .result-arrow {
    opacity: 1;
    transform: translateX(0);
}

/* ============================================
   Not Found State
   ============================================ */
.dpdpa-search-not-found,
.dpdpa-search-no-results {
    text-align: center;
    padding: 40px 20px;
}

.not-found-icon,
.no-results-icon {
    margin-bottom: 16px;
}

.dpdpa-search-not-found h4,
.dpdpa-search-no-results h4 {
    margin: 0 0 8px 0;
    font-size: 18px;
    font-weight: 600;
    color: var(--dpdpa-text);
}

.dpdpa-search-not-found p,
.dpdpa-search-no-results p {
    margin: 0 0 20px 0;
    color: var(--dpdpa-text-light);
    font-size: 14px;
}

.not-found-suggestions {
    padding-top: 16px;
    border-top: 1px solid var(--dpdpa-border);
}

.not-found-suggestions p {
    font-size: 13px;
    color: var(--dpdpa-text-muted);
    margin-bottom: 12px;
}

.suggestion-buttons {
    display: flex;
    gap: 8px;
    justify-content: center;
    flex-wrap: wrap;
}

.suggestion-buttons button {
    padding: 8px 16px;
    border: 1px solid var(--dpdpa-primary);
    background: var(--dpdpa-primary-light);
    color: var(--dpdpa-primary);
    border-radius: var(--dpdpa-radius-sm);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--dpdpa-transition);
    font-family: inherit;
}

.suggestion-buttons button:hover {
    background: var(--dpdpa-primary);
    color: white;
}

/* ============================================
   Search Footer
   ============================================ */
.dpdpa-search-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    background: var(--dpdpa-bg-light);
    border-top: 1px solid var(--dpdpa-border);
    font-size: 12px;
    color: var(--dpdpa-text-muted);
}

.footer-nav {
    display: flex;
    gap: 16px;
}

.footer-nav span {
    display: flex;
    align-items: center;
    gap: 4px;
}

.footer-nav kbd {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 22px;
    padding: 0 6px;
    background: var(--dpdpa-bg);
    border: 1px solid var(--dpdpa-border);
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    font-family: inherit;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.footer-brand {
    font-weight: 600;
    color: var(--dpdpa-primary);
}

/* ============================================
   Mobile Responsive Styles
   ============================================ */
@media (max-width: 768px) {
    .dpdpa-search-btn {
        top: auto;
        bottom: 20px;
        right: 20px;
        width: 56px;
        height: 56px;
    }
    
    .dpdpa-search-overlay {
        padding: 5vh 12px 12px;
        align-items: flex-start;
    }
    
    .dpdpa-search-modal {
        max-height: 90vh;
        border-radius: var(--dpdpa-radius);
    }
    
    .dpdpa-search-header {
        padding: 12px 16px;
    }
    
    .dpdpa-search-input-wrapper {
        padding: 0 12px;
    }
    
    .dpdpa-search-input {
        padding: 12px 0;
        font-size: 16px; /* Prevents iOS zoom */
    }
    
    .dpdpa-search-shortcut {
        display: none;
    }
    
    .dpdpa-search-results {
        padding: 12px;
        max-height: 50vh;
    }
    
    .tip-grid {
        grid-template-columns: 1fr;
    }
    
    .result-item {
        padding: 12px;
    }
    
    .result-icon {
        width: 36px;
        height: 36px;
        font-size: 16px;
    }
    
    .result-title {
        font-size: 14px;
    }
    
    .result-subtitle {
        font-size: 13px;
    }
    
    .footer-nav {
        gap: 10px;
        font-size: 11px;
    }
    
    .footer-nav kbd {
        min-width: 20px;
        height: 20px;
        font-size: 10px;
    }
}

@media (max-width: 480px) {
    .dpdpa-search-btn {
        width: 52px;
        height: 52px;
        right: 16px;
        bottom: 16px;
    }
    
    .dpdpa-search-overlay {
        padding: 2vh 8px 8px;
    }
    
    .tip-item {
        padding: 8px 10px;
    }
    
    .tip-item code {
        font-size: 12px;
        padding: 3px 6px;
    }
    
    .tip-item span {
        font-size: 12px;
    }
    
    .result-item {
        gap: 10px;
        padding: 10px;
    }
    
    .result-icon {
        width: 32px;
        height: 32px;
        font-size: 14px;
    }
    
    .footer-nav span:not(:first-child) {
        display: none;
    }
}

/* ============================================
   Animation for results
   ============================================ */
@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.result-item {
    animation: slideIn 0.2s ease forwards;
}

.result-item:nth-child(2) { animation-delay: 0.03s; }
.result-item:nth-child(3) { animation-delay: 0.06s; }
.result-item:nth-child(4) { animation-delay: 0.09s; }
.result-item:nth-child(5) { animation-delay: 0.12s; }
.result-item:nth-child(6) { animation-delay: 0.15s; }
.result-item:nth-child(7) { animation-delay: 0.18s; }
.result-item:nth-child(8) { animation-delay: 0.21s; }
.result-item:nth-child(9) { animation-delay: 0.24s; }
.result-item:nth-child(10) { animation-delay: 0.27s; }

/* ============================================
   Scrollbar Styling
   ============================================ */
.dpdpa-search-results::-webkit-scrollbar {
    width: 6px;
}

.dpdpa-search-results::-webkit-scrollbar-track {
    background: var(--dpdpa-bg-light);
    border-radius: 3px;
}

.dpdpa-search-results::-webkit-scrollbar-thumb {
    background: var(--dpdpa-border);
    border-radius: 3px;
}

.dpdpa-search-results::-webkit-scrollbar-thumb:hover {
    background: var(--dpdpa-text-muted);
}

/* ============================================
   Print Styles
   ============================================ */
@media print {
    #dpdpa-search-container {
        display: none !important;
    }
}

/* ============================================
   High Contrast Mode
   ============================================ */
@media (prefers-contrast: high) {
    .dpdpa-search-input-wrapper {
        border-width: 3px;
    }
    
    .result-item {
        border-width: 2px;
    }
}

/* ============================================
   Reduced Motion
   ============================================ */
@media (prefers-reduced-motion: reduce) {
    .dpdpa-search-btn,
    .dpdpa-search-overlay,
    .dpdpa-search-modal,
    .result-item,
    .result-arrow {
        transition: none;
    }
    
    .result-item {
        animation: none;
    }
}
