/**
 * SP Pagadian Archive - Official Profiles Enhancement Module Styles
 * Version: 1.0.0
 * Date: 2025-12-19
 *
 * Features:
 * - Responsive photo gallery grid
 * - Circular photo frames with hover effects
 * - District tabs and term selector
 * - Official detail modal
 * - Dark mode support
 * - Print-friendly layout
 */

/* ===========================
   Variables
   =========================== */
:root {
    --op-primary: #2563eb;
    --op-primary-dark: #1e40af;
    --op-primary-light: #3b82f6;

    --op-bg-primary: #ffffff;
    --op-bg-secondary: #f9fafb;
    --op-bg-tertiary: #f3f4f6;

    --op-text-primary: #111827;
    --op-text-secondary: #6b7280;
    --op-text-tertiary: #9ca3af;

    --op-border: #e5e7eb;
    --op-border-light: #f3f4f6;

    --op-shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --op-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    --op-shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --op-shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --op-shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);

    --op-radius-sm: 0.25rem;
    --op-radius: 0.375rem;
    --op-radius-md: 0.5rem;
    --op-radius-lg: 0.75rem;
    --op-radius-xl: 1rem;
    --op-radius-full: 9999px;

    --op-transition: all 0.15s ease-in-out;
}

/* Dark mode */
@media (prefers-color-scheme: dark) {
    :root {
        --op-bg-primary: #1f2937;
        --op-bg-secondary: #111827;
        --op-bg-tertiary: #374151;

        --op-text-primary: #f9fafb;
        --op-text-secondary: #d1d5db;
        --op-text-tertiary: #9ca3af;

        --op-border: #374151;
        --op-border-light: #4b5563;
    }
}

/* Custom dark mode class */
.dark-mode {
    --op-bg-primary: #1f2937;
    --op-bg-secondary: #111827;
    --op-bg-tertiary: #374151;

    --op-text-primary: #f9fafb;
    --op-text-secondary: #d1d5db;
    --op-text-tertiary: #9ca3af;

    --op-border: #374151;
    --op-border-light: #4b5563;
}

/* ===========================
   Base Module Container
   =========================== */
.official-profiles-module {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1.5rem;
}

/* ===========================
   Header
   =========================== */
.op-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    gap: 1.5rem;
}

.op-header-content {
    flex: 1;
    min-width: 200px;
}

.op-title {
    font-size: 2rem;
    font-weight: 700;
    color: var(--op-text-primary);
    margin: 0 0 0.25rem 0;
}

.op-subtitle {
    font-size: 1rem;
    color: var(--op-text-secondary);
    margin: 0;
}

.op-header-actions {
    display: flex;
    gap: 1rem;
    align-items: center;
    flex-wrap: wrap;
}

/* Term Selector */
.op-term-selector {
    position: relative;
}

.op-select {
    appearance: none;
    background-color: var(--op-bg-primary);
    border: 1px solid var(--op-border);
    border-radius: var(--op-radius);
    padding: 0.5rem 2.5rem 0.5rem 1rem;
    font-size: 0.875rem;
    color: var(--op-text-primary);
    cursor: pointer;
    transition: var(--op-transition);
    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;
    min-width: 200px;
}

.op-select:hover {
    border-color: var(--op-primary);
}

.op-select:focus {
    outline: none;
    border-color: var(--op-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* Search Box */
.op-search-box {
    position: relative;
    min-width: 250px;
}

.op-search-input {
    width: 100%;
    padding: 0.5rem 1rem 0.5rem 2.5rem;
    border: 1px solid var(--op-border);
    border-radius: var(--op-radius);
    font-size: 0.875rem;
    color: var(--op-text-primary);
    background-color: var(--op-bg-primary);
    transition: var(--op-transition);
}

.op-search-input::placeholder {
    color: var(--op-text-tertiary);
}

.op-search-input:focus {
    outline: none;
    border-color: var(--op-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.op-search-icon {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    width: 1.25rem;
    height: 1.25rem;
    color: var(--op-text-tertiary);
    pointer-events: none;
}

/* 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;
}

/* ===========================
   Filters
   =========================== */
.op-filters {
    margin-bottom: 2rem;
}

.op-district-tabs {
    display: flex;
    gap: 0.5rem;
    border-bottom: 2px solid var(--op-border);
    overflow-x: auto;
    scrollbar-width: thin;
}

.op-district-tabs::-webkit-scrollbar {
    height: 4px;
}

.op-district-tabs::-webkit-scrollbar-thumb {
    background: var(--op-border);
    border-radius: var(--op-radius-full);
}

.op-tab {
    padding: 0.75rem 1.5rem;
    border: none;
    background: none;
    color: var(--op-text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    position: relative;
    white-space: nowrap;
    transition: var(--op-transition);
}

.op-tab:hover {
    color: var(--op-text-primary);
    background-color: var(--op-bg-secondary);
}

.op-tab.active {
    color: var(--op-primary);
    font-weight: 600;
}

.op-tab.active::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    right: 0;
    height: 2px;
    background-color: var(--op-primary);
}

/* ===========================
   Gallery Grid
   =========================== */
.op-gallery {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 2rem;
    margin-bottom: 2rem;
}

/* Tablet */
@media (max-width: 1024px) {
    .op-gallery {
        grid-template-columns: repeat(3, 1fr);
        gap: 1.5rem;
    }
}

/* Small Tablet */
@media (max-width: 768px) {
    .op-gallery {
        grid-template-columns: repeat(2, 1fr);
        gap: 1.25rem;
    }

    .op-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .op-header-actions {
        width: 100%;
        flex-direction: column;
    }

    .op-search-box,
    .op-select {
        width: 100%;
        min-width: auto;
    }
}

/* Mobile */
@media (max-width: 480px) {
    .official-profiles-module {
        padding: 1rem;
    }

    .op-gallery {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .op-title {
        font-size: 1.5rem;
    }
}

/* ===========================
   Official Card
   =========================== */
.op-card {
    background-color: var(--op-bg-primary);
    border: 1px solid var(--op-border);
    border-radius: var(--op-radius-lg);
    padding: 1.5rem;
    text-align: center;
    cursor: pointer;
    transition: var(--op-transition);
    box-shadow: var(--op-shadow-sm);
}

.op-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--op-shadow-lg);
    border-color: var(--op-primary-light);
}

.op-card-photo-wrapper {
    width: 120px;
    height: 120px;
    margin: 0 auto 1rem;
    position: relative;
    border-radius: var(--op-radius-full);
    overflow: hidden;
    border: 3px solid var(--op-border);
    transition: var(--op-transition);
}

.op-card:hover .op-card-photo-wrapper {
    border-color: var(--op-primary);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.1);
}

.op-card-photo {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.op-card-photo-fallback {
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, var(--op-primary), var(--op-primary-dark));
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    font-weight: 700;
}

.op-card-content {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.op-card-name {
    font-size: 1rem;
    font-weight: 600;
    color: var(--op-text-primary);
    margin: 0;
    line-height: 1.4;
}

.op-card-position {
    font-size: 0.875rem;
    color: var(--op-text-secondary);
    margin: 0;
    font-weight: 500;
}

.op-card-district {
    font-size: 0.75rem;
    color: var(--op-text-tertiary);
    margin: 0;
}

.op-card-committees {
    margin-top: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    align-items: center;
}

.op-committee-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    background-color: var(--op-bg-secondary);
    color: var(--op-text-secondary);
    font-size: 0.75rem;
    border-radius: var(--op-radius-full);
    font-weight: 500;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.op-committee-more {
    font-size: 0.75rem;
    color: var(--op-primary);
    font-weight: 500;
}

/* ===========================
   Empty State
   =========================== */
.op-empty-state {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--op-text-secondary);
}

.op-empty-icon {
    width: 4rem;
    height: 4rem;
    margin: 0 auto 1rem;
    opacity: 0.5;
}

.op-empty-state p {
    font-size: 1rem;
    margin: 0;
}

/* ===========================
   Error State
   =========================== */
.op-error {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--op-text-secondary);
}

.op-error-icon {
    width: 4rem;
    height: 4rem;
    margin: 0 auto 1rem;
    color: #ef4444;
}

.op-error h2 {
    font-size: 1.5rem;
    color: var(--op-text-primary);
    margin: 0 0 0.5rem 0;
}

.op-error p {
    font-size: 1rem;
    margin: 0;
}

/* ===========================
   Modal
   =========================== */
.op-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    opacity: 0;
    transition: opacity 0.2s ease-in-out;
}

.op-modal.active {
    opacity: 1;
}

.op-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(4px);
}

.op-modal-content {
    position: relative;
    background-color: var(--op-bg-primary);
    border-radius: var(--op-radius-xl);
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--op-shadow-xl);
    transform: scale(0.95);
    transition: transform 0.2s ease-in-out;
}

.op-modal.active .op-modal-content {
    transform: scale(1);
}

.op-modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 2.5rem;
    height: 2.5rem;
    border: none;
    background-color: var(--op-bg-secondary);
    color: var(--op-text-secondary);
    font-size: 1.5rem;
    border-radius: var(--op-radius-full);
    cursor: pointer;
    transition: var(--op-transition);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.op-modal-close:hover {
    background-color: var(--op-bg-tertiary);
    color: var(--op-text-primary);
}

.op-modal-header {
    display: flex;
    gap: 1.5rem;
    padding: 2rem;
    border-bottom: 1px solid var(--op-border);
    align-items: center;
}

.op-modal-photo-wrapper {
    width: 100px;
    height: 100px;
    flex-shrink: 0;
    border-radius: var(--op-radius-full);
    overflow: hidden;
    border: 3px solid var(--op-border);
}

.op-modal-photo {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.op-modal-photo-fallback {
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, var(--op-primary), var(--op-primary-dark));
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    font-weight: 700;
}

.op-modal-header-text {
    flex: 1;
}

.op-modal-name {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--op-text-primary);
    margin: 0 0 0.25rem 0;
}

.op-modal-position {
    font-size: 1rem;
    color: var(--op-text-secondary);
    margin: 0 0 0.25rem 0;
    font-weight: 500;
}

.op-modal-district {
    font-size: 0.875rem;
    color: var(--op-text-tertiary);
    margin: 0;
}

.op-modal-body {
    padding: 2rem;
}

.op-modal-section {
    margin-bottom: 2rem;
}

.op-modal-section:last-child {
    margin-bottom: 0;
}

.op-modal-section h3 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--op-text-primary);
    margin: 0 0 1rem 0;
}

.op-modal-section p {
    font-size: 0.938rem;
    line-height: 1.6;
    color: var(--op-text-secondary);
    margin: 0;
}

/* Committee List */
.op-committee-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.op-committee-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    background-color: var(--op-bg-secondary);
    border-radius: var(--op-radius);
    font-size: 0.875rem;
    color: var(--op-text-primary);
}

.op-committee-icon {
    width: 1.25rem;
    height: 1.25rem;
    color: var(--op-primary);
    flex-shrink: 0;
}

/* Contact List */
.op-contact-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.op-contact-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.875rem;
}

.op-contact-icon {
    width: 1.25rem;
    height: 1.25rem;
    color: var(--op-text-tertiary);
    flex-shrink: 0;
}

.op-contact-item a {
    color: var(--op-primary);
    text-decoration: none;
    transition: var(--op-transition);
}

.op-contact-item a:hover {
    color: var(--op-primary-dark);
    text-decoration: underline;
}

/* Social Links */
.op-social-links {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.op-social-link {
    padding: 0.5rem 1rem;
    background-color: var(--op-bg-secondary);
    color: var(--op-text-primary);
    font-size: 0.875rem;
    border-radius: var(--op-radius);
    text-decoration: none;
    transition: var(--op-transition);
    font-weight: 500;
}

.op-social-link:hover {
    background-color: var(--op-primary);
    color: white;
}

/* Modal Responsive */
@media (max-width: 640px) {
    .op-modal-header {
        flex-direction: column;
        text-align: center;
        padding: 1.5rem;
    }

    .op-modal-photo-wrapper {
        width: 80px;
        height: 80px;
    }

    .op-modal-name {
        font-size: 1.25rem;
    }

    .op-modal-body {
        padding: 1.5rem;
    }

    .op-modal-close {
        top: 0.5rem;
        right: 0.5rem;
    }
}

/* ===========================
   Print Styles
   =========================== */
@media print {
    .official-profiles-module {
        max-width: none;
        padding: 0;
    }

    .op-header-actions,
    .op-filters,
    .op-modal-close {
        display: none !important;
    }

    .op-gallery {
        grid-template-columns: repeat(3, 1fr);
        gap: 1rem;
        page-break-inside: avoid;
    }

    .op-card {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #000;
    }

    .op-card:hover {
        transform: none;
    }

    .op-modal {
        position: relative;
        padding: 0;
    }

    .op-modal-overlay {
        display: none;
    }

    .op-modal-content {
        max-width: none;
        max-height: none;
        box-shadow: none;
        page-break-inside: avoid;
    }

    .op-card-photo-wrapper,
    .op-modal-photo-wrapper {
        border-color: #000;
    }

    /* Force light mode for print */
    :root {
        --op-bg-primary: #ffffff;
        --op-bg-secondary: #f9fafb;
        --op-bg-tertiary: #f3f4f6;
        --op-text-primary: #111827;
        --op-text-secondary: #6b7280;
        --op-text-tertiary: #9ca3af;
        --op-border: #e5e7eb;
    }
}

/* ===========================
   Animations
   =========================== */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.op-card {
    animation: fadeIn 0.3s ease-out;
}

/* Stagger animation for cards */
.op-card:nth-child(1) { animation-delay: 0.05s; }
.op-card:nth-child(2) { animation-delay: 0.1s; }
.op-card:nth-child(3) { animation-delay: 0.15s; }
.op-card:nth-child(4) { animation-delay: 0.2s; }
.op-card:nth-child(5) { animation-delay: 0.25s; }
.op-card:nth-child(6) { animation-delay: 0.3s; }
.op-card:nth-child(7) { animation-delay: 0.35s; }
.op-card:nth-child(8) { animation-delay: 0.4s; }

/* ===========================
   Accessibility
   =========================== */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .op-card:hover {
        transform: none;
    }
}

/* Focus visible for keyboard navigation */
.op-card:focus-visible,
.op-tab:focus-visible,
.op-select:focus-visible,
.op-search-input:focus-visible {
    outline: 2px solid var(--op-primary);
    outline-offset: 2px;
}

/* High contrast mode */
@media (prefers-contrast: high) {
    .op-card {
        border-width: 2px;
    }

    .op-tab.active::after {
        height: 3px;
    }
}
