/**
 * PSM Inversión Social - Portfolio Styles
 * Estilos modernos para el portfolio de organizaciones
 */

/* =============================================
   Variables CSS
   ============================================= */
:root {
    --psm-primary: #4ECDC4;
    --psm-primary-dark: #3db9b0;
    --psm-secondary: #FF6B9D;
    --psm-text: #1a1a2e;
    --psm-text-light: #666666;
    --psm-text-muted: #999999;
    --psm-bg: #f8f9fa;
    --psm-white: #ffffff;
    --psm-border: #e9ecef;
    --psm-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    --psm-shadow-hover: 0 8px 30px rgba(0, 0, 0, 0.12);
    --psm-radius: 16px;
    --psm-radius-sm: 8px;
    --psm-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* =============================================
   Portfolio Wrapper
   ============================================= */
.psm-portfolio-wrapper {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    max-width: 1400px;
    margin: 0 auto;
    padding: 40px 20px;
}

/* =============================================
   Controls (Search & Filter)
   ============================================= */
.psm-portfolio-controls {
    margin-bottom: 40px;
}

/* Search Box */
.psm-search-box {
    position: relative;
    max-width: 400px;
    margin-bottom: 24px;
}

.psm-search-input {
    width: 100%;
    padding: 14px 20px 14px 50px;
    font-size: 16px;
    border: 2px solid var(--psm-border);
    border-radius: 50px;
    background: var(--psm-white);
    transition: var(--psm-transition);
    outline: none;
}

.psm-search-input:focus {
    border-color: var(--psm-primary);
    box-shadow: 0 0 0 4px rgba(78, 205, 196, 0.15);
}

.psm-search-icon {
    position: absolute;
    left: 18px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--psm-text-muted);
    pointer-events: none;
}

/* Filter Buttons */
.psm-filter-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    padding: 4px;
}

.psm-filter-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 500;
    color: var(--psm-text);
    background: var(--psm-white);
    border: 2px solid var(--psm-border);
    border-radius: 50px;
    cursor: pointer;
    transition: var(--psm-transition);
    white-space: nowrap;
}

.psm-filter-btn:hover {
    border-color: var(--psm-primary);
    color: var(--psm-primary);
    transform: translateY(-2px);
}

.psm-filter-btn.active {
    background: var(--psm-primary);
    border-color: var(--psm-primary);
    color: var(--psm-white);
    box-shadow: 0 4px 15px rgba(78, 205, 196, 0.35);
}

.psm-filter-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 24px;
    height: 24px;
    padding: 0 8px;
    font-size: 12px;
    font-weight: 600;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 12px;
}

.psm-filter-btn.active .psm-filter-count {
    background: rgba(255, 255, 255, 0.25);
}

/* =============================================
   Portfolio Grid
   ============================================= */
.psm-portfolio-grid {
    display: grid;
    gap: 24px;
}

.psm-cols-1 { grid-template-columns: 1fr; }
.psm-cols-2 { grid-template-columns: repeat(2, 1fr); }
.psm-cols-3 { grid-template-columns: repeat(3, 1fr); }
.psm-cols-4 { grid-template-columns: repeat(4, 1fr); }

/* Responsive Grid */
@media (max-width: 1200px) {
    .psm-cols-4 { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 992px) {
    .psm-cols-3,
    .psm-cols-4 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
    .psm-cols-2,
    .psm-cols-3,
    .psm-cols-4 { grid-template-columns: 1fr; }
    
    .psm-filter-buttons {
        overflow-x: auto;
        flex-wrap: nowrap;
        padding-bottom: 10px;
        margin: 0 -20px;
        padding-left: 20px;
        padding-right: 20px;
    }
    
    .psm-filter-buttons::-webkit-scrollbar {
        display: none;
    }
}

/* =============================================
   Organization Card
   ============================================= */
.psm-org-card {
    background: var(--psm-white);
    border-radius: var(--psm-radius);
    box-shadow: var(--psm-shadow);
    overflow: hidden;
    transition: var(--psm-transition);
    display: flex;
    flex-direction: column;
}

.psm-org-card:hover {
    transform: translateY(-8px);
    box-shadow: var(--psm-shadow-hover);
}

/* Card Header */
.psm-org-card-header {
    position: relative;
    padding: 30px 24px;
    min-height: 140px;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: center;
}

/* Causa Badge */
.psm-causa-badge {
    position: absolute;
    top: 16px;
    left: 16px;
    padding: 6px 14px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--psm-white);
    border-radius: 50px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

/* Organization Logo */
.psm-org-logo {
    width: 90px;
    height: 90px;
    border-radius: 50%;
    overflow: hidden;
    background: var(--psm-white);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: -45px;
    position: relative;
    z-index: 2;
}

.psm-org-logo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.psm-org-logo-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    font-weight: 700;
    color: var(--psm-white);
    text-transform: uppercase;
}

/* Card Content */
.psm-org-card-content {
    padding: 60px 24px 24px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* Title */
.psm-org-title {
    margin: 0 0 8px;
    font-size: 18px;
    font-weight: 700;
    color: var(--psm-text);
    text-align: center;
    line-height: 1.3;
}

/* Temporalidad */
.psm-org-temporalidad {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-size: 12px;
    color: var(--psm-text-muted);
    margin-bottom: 16px;
}

.psm-org-temporalidad svg {
    color: var(--psm-primary);
}

/* Description */
.psm-org-description {
    margin: 0 0 20px;
    font-size: 14px;
    line-height: 1.6;
    color: var(--psm-text-light);
    text-align: center;
    flex: 1;
}

/* Meta Information */
.psm-org-meta {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 20px;
    padding: 16px;
    background: var(--psm-bg);
    border-radius: var(--psm-radius-sm);
}

.psm-org-meta-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    font-size: 13px;
    color: var(--psm-text-light);
}

.psm-org-meta-item svg {
    flex-shrink: 0;
    margin-top: 2px;
    color: var(--psm-primary);
}

.psm-org-meta-item span {
    line-height: 1.4;
}

/* Actions / Button */
.psm-org-actions {
    margin-top: auto;
}

.psm-org-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 14px 24px;
    font-size: 14px;
    font-weight: 600;
    color: var(--psm-white);
    background: var(--psm-primary);
    border: none;
    border-radius: var(--psm-radius-sm);
    cursor: pointer;
    transition: var(--psm-transition);
    text-decoration: none;
}

.psm-org-button:hover {
    background: var(--psm-primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(78, 205, 196, 0.4);
    color: var(--psm-white);
    text-decoration: none;
}

.psm-org-button svg {
    transition: transform 0.3s ease;
}

.psm-org-button:hover svg {
    transform: translateX(4px);
}

/* =============================================
   No Results
   ============================================= */
.psm-no-results {
    grid-column: 1 / -1;
    text-align: center;
    padding: 60px 20px;
    background: var(--psm-bg);
    border-radius: var(--psm-radius);
}

.psm-no-results p {
    margin: 0;
    font-size: 18px;
    color: var(--psm-text-muted);
}

/* =============================================
   Loading State
   ============================================= */
.psm-loading {
    position: relative;
    min-height: 200px;
}

.psm-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    margin: -20px 0 0 -20px;
    border: 3px solid var(--psm-border);
    border-top-color: var(--psm-primary);
    border-radius: 50%;
    animation: psm-spin 0.8s linear infinite;
}

@keyframes psm-spin {
    to { transform: rotate(360deg); }
}

/* =============================================
   Card Animation on Filter
   ============================================= */
.psm-org-card {
    animation: psm-fade-in 0.4s ease forwards;
}

.psm-org-card.psm-hidden {
    display: none;
}

@keyframes psm-fade-in {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Stagger animation */
.psm-org-card:nth-child(1) { animation-delay: 0.05s; }
.psm-org-card:nth-child(2) { animation-delay: 0.1s; }
.psm-org-card:nth-child(3) { animation-delay: 0.15s; }
.psm-org-card:nth-child(4) { animation-delay: 0.2s; }
.psm-org-card:nth-child(5) { animation-delay: 0.25s; }
.psm-org-card:nth-child(6) { animation-delay: 0.3s; }
.psm-org-card:nth-child(7) { animation-delay: 0.35s; }
.psm-org-card:nth-child(8) { animation-delay: 0.4s; }
.psm-org-card:nth-child(9) { animation-delay: 0.45s; }

/* =============================================
   List Layout
   ============================================= */
.psm-layout-list .psm-portfolio-grid {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.psm-layout-list .psm-org-card {
    flex-direction: row;
    align-items: stretch;
}

.psm-layout-list .psm-org-card-header {
    width: 200px;
    min-height: auto;
    flex-shrink: 0;
    padding: 20px;
}

.psm-layout-list .psm-org-logo {
    width: 70px;
    height: 70px;
    margin-bottom: 0;
}

.psm-layout-list .psm-org-card-content {
    padding: 24px;
    text-align: left;
}

.psm-layout-list .psm-org-title,
.psm-layout-list .psm-org-temporalidad,
.psm-layout-list .psm-org-description {
    text-align: left;
}

.psm-layout-list .psm-org-temporalidad {
    justify-content: flex-start;
}

.psm-layout-list .psm-org-meta {
    flex-direction: row;
    flex-wrap: wrap;
}

.psm-layout-list .psm-org-actions {
    margin-top: auto;
}

.psm-layout-list .psm-org-button {
    width: auto;
}

@media (max-width: 768px) {
    .psm-layout-list .psm-org-card {
        flex-direction: column;
    }
    
    .psm-layout-list .psm-org-card-header {
        width: 100%;
    }
    
    .psm-layout-list .psm-org-logo {
        margin-bottom: -35px;
    }
    
    .psm-layout-list .psm-org-card-content {
        padding-top: 50px;
        text-align: center;
    }
    
    .psm-layout-list .psm-org-title,
    .psm-layout-list .psm-org-temporalidad,
    .psm-layout-list .psm-org-description {
        text-align: center;
    }
    
    .psm-layout-list .psm-org-temporalidad {
        justify-content: center;
    }
    
    .psm-layout-list .psm-org-button {
        width: 100%;
    }
}

/* =============================================
   Color Variations for Causas
   ============================================= */

/* Primera Infancia - Pink */
.psm-org-card[data-causa*="primera-infancia"] .psm-causa-badge {
    background: #FF6B9D;
}

/* Educación - Teal */
.psm-org-card[data-causa*="educacion"] .psm-causa-badge {
    background: #4ECDC4;
}

/* Emprendimiento Social - Yellow */
.psm-org-card[data-causa*="emprendimiento"] .psm-causa-badge {
    background: #F7B731;
    color: #333;
}

/* Juventud - Green */
.psm-org-card[data-causa*="juventud"] .psm-causa-badge {
    background: #26DE81;
}

/* Salud - Red */
.psm-org-card[data-causa*="salud"] .psm-causa-badge {
    background: #FC5C65;
}

/* Fortalecimiento Ecosistema - Purple */
.psm-org-card[data-causa*="fortalecimiento"] .psm-causa-badge {
    background: #A55EEA;
}

/* Acción Humanitaria - Orange */
.psm-org-card[data-causa*="accion-humanitaria"] .psm-causa-badge {
    background: #FD9644;
}

/* =============================================
   Modal for Detail View (optional)
   ============================================= */
.psm-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    visibility: hidden;
    transition: var(--psm-transition);
}

.psm-modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.psm-modal-content {
    background: var(--psm-white);
    border-radius: var(--psm-radius);
    max-width: 700px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    transform: scale(0.9);
    transition: var(--psm-transition);
}

.psm-modal-overlay.active .psm-modal-content {
    transform: scale(1);
}

.psm-modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 40px;
    height: 40px;
    border: none;
    background: var(--psm-white);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--psm-shadow);
    transition: var(--psm-transition);
}

.psm-modal-close:hover {
    background: var(--psm-primary);
    color: var(--psm-white);
}

/* =============================================
   Print Styles
   ============================================= */
@media print {
    .psm-portfolio-controls {
        display: none;
    }
    
    .psm-org-card {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #ddd;
    }
    
    .psm-org-button {
        display: none;
    }
}
