/**
 * Shared component styles for Servico platform
 * Consolidates inline <style> blocks from across the codebase
 */

/* ==========================================
   Alpine.js Cloak
   ========================================== */
[x-cloak] { display: none !important; }

/* ==========================================
   Global Layout
   ========================================== */
html, body {
    overflow-x: hidden;
}

/* ==========================================
   Search Container
   ========================================== */
.search-container {
    background: #ffffff;
    border-radius: 12px;
    padding: 2rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    border: 1px solid #e5e7eb;
}

/* Search type tab styles */
.search-tab {
    color: #6b7280;
    background: transparent;
}
.search-tab:hover {
    background: rgba(255,255,255,0.6);
}
.search-tab.active-tab[data-type="anunturi"] {
    background: #2563eb;
    color: #fff;
    box-shadow: 0 1px 3px rgba(37, 99, 235, 0.3);
}
.search-tab.active-tab[data-type="cereri"] {
    background: #ea580c;
    color: #fff;
    box-shadow: 0 1px 3px rgba(234, 88, 12, 0.3);
}

/* ==========================================
   Autocomplete Dropdown
   ========================================== */
.autocomplete-items {
    position: absolute;
    border: 1px solid #e5e7eb;
    border-top: none;
    z-index: 50;
    background-color: #fff;
    max-height: 200px;
    overflow-y: auto;
    width: calc(100% - 2px);
    top: 100%;
    left: 0;
    border-radius: 0 0 12px 12px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}
.autocomplete-item {
    padding: 12px 16px;
    cursor: pointer;
    transition: all 0.2s;
    border-bottom: 1px solid #f3f4f6;
}
.autocomplete-item:hover {
    background: #2563eb;
    color: white;
}
.autocomplete-item:last-child {
    border-bottom: none;
}

/* Orange variant for cereri pages */
.autocomplete-orange .autocomplete-item:hover {
    background: #f97316;
}

/* ==========================================
   Category Scroll (hide scrollbar)
   ========================================== */
.category-scroll::-webkit-scrollbar { display: none; }
.category-scroll { -ms-overflow-style: none; scrollbar-width: none; -webkit-overflow-scrolling: touch; }

/* ==========================================
   Text Utilities
   ========================================== */
.prose p {
    word-wrap: break-word;
    word-break: break-word;
    overflow-wrap: break-word;
}
.line-clamp-3 {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ==========================================
   Loading / Spinner
   ========================================== */
@keyframes spin {
    to { transform: rotate(360deg); }
}
.spinner {
    animation: spin 0.6s linear infinite;
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    vertical-align: middle;
    margin-right: 8px;
}
.btn-loading {
    opacity: 0.7;
    cursor: not-allowed;
}
.loading-spinner {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255,255,255,.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 0.8s linear infinite;
}

/* ==========================================
   OTP Input Boxes
   ========================================== */
.otp-boxes {
    display: flex;
    gap: 8px;
    justify-content: center;
}
.otp-box {
    width: 44px;
    height: 52px;
    text-align: center;
    font-size: 22px;
    font-weight: 700;
    border: 2px solid #cbd5e1;
    border-radius: 0.75rem;
    outline: none;
    transition: all 0.2s;
    caret-color: transparent;
}
.otp-box:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59,130,246,0.2);
}
.otp-box.filled {
    border-color: #3b82f6;
    background-color: #eff6ff;
}
.otp-box.error {
    border-color: #ef4444;
    background-color: #fef2f2;
}
@media (min-width: 640px) {
    .otp-box { width: 56px; height: 64px; font-size: 28px; }
}

/* Phone input */
.phone-input { font-size: 18px; letter-spacing: 1px; }

/* ==========================================
   Shake Animation
   ========================================== */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-4px); }
    20%, 40%, 60%, 80% { transform: translateX(4px); }
}
.shake { animation: shake 0.5s ease-in-out; }

/* ==========================================
   Success Icon Animation (pending/confirmation pages)
   ========================================== */
.success-icon {
    animation: scaleIn 0.5s ease-out;
}
.checkmark-draw {
    stroke-dasharray: 48;
    stroke-dashoffset: 48;
    animation: drawCheck 0.4s ease-in-out 0.5s forwards;
}
@keyframes scaleIn {
    0% { transform: scale(0); }
    100% { transform: scale(1); }
}
@keyframes drawCheck {
    100% { stroke-dashoffset: 0; }
}

/* ==========================================
   Risk Score Bars (moderation)
   ========================================== */
.risk-bar {
    height: 8px;
    border-radius: 4px;
    overflow: hidden;
    background: #e2e8f0;
}
.risk-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.3s ease;
}
.risk-low { background: #16a34a; }
.risk-medium { background: #f59e0b; }
.risk-high { background: #ef4444; }

/* Risk meter (detail view) */
.risk-meter {
    position: relative;
    height: 32px;
    background: linear-gradient(to right, #16a34a 0%, #f59e0b 50%, #ef4444 100%);
    border-radius: 16px;
    overflow: hidden;
}
.risk-indicator {
    position: absolute;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 4px;
    height: 40px;
    background: #1e293b;
    border-radius: 2px;
    box-shadow: 0 0 8px rgba(0,0,0,0.3);
}
.risk-bar-sm {
    height: 6px;
    border-radius: 3px;
    overflow: hidden;
    background: #e2e8f0;
}
.risk-fill-sm {
    height: 100%;
    border-radius: 3px;
    transition: width 0.3s ease;
}

/* ==========================================
   Map Page
   ========================================== */
/* Ensure map and all Leaflet controls stay below navbar */
.leaflet-container,
.leaflet-pane,
.leaflet-top,
.leaflet-bottom,
.leaflet-control-container,
.leaflet-control {
    z-index: 1 !important;
}

#map {
    height: 100%;
    width: 100%;
    position: relative;
    z-index: 1;
}

.leaflet-popup-content {
    min-width: 220px;
    max-width: 300px;
    margin: 8px 12px;
}

.leaflet-popup-content-wrapper {
    border-radius: 12px;
    padding: 0;
    overflow: hidden;
}

/* Sidebar list scrollbar */
.sidebar-list::-webkit-scrollbar {
    width: 4px;
}
.sidebar-list::-webkit-scrollbar-track {
    background: transparent;
}
.sidebar-list::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 2px;
}

/* Bottom sheet transition */
.bottom-sheet {
    transition: transform 0.3s ease-out;
}
.bottom-sheet.collapsed {
    transform: translateY(calc(100% - 48px));
}

/* ==========================================
   Mobile Bottom Navbar Spacing
   ========================================== */
@media (max-width: 768px) {
    body {
        padding-bottom: 80px; /* Space for bottom navbar */
    }
    .leaflet-container,
    .leaflet-pane,
    .leaflet-top,
    .leaflet-bottom,
    .leaflet-control-container,
    .leaflet-control,
    .leaflet-popup-pane,
    .leaflet-marker-pane {
        z-index: 1 !important;
    }
    header,
    nav {
        z-index: 1000 !important;
    }
}

/* ==========================================
   Admin Nav
   ========================================== */
.admin-body {
    padding-top: 64px;
}

/* ==========================================
   Accessibility: Focus Visible
   ========================================== */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
    border-radius: 4px;
}

/* ==========================================
   Accessibility: Screen Reader Only
   ========================================== */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* ==========================================
   Accessibility: Reduced Motion
   ========================================== */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}
