/**
 * IIIVP Project Manager - Complete Styles
 * Version: 1.1.0
 * Author: Ikram Anjum
 */

/* ===================================
   ADMIN STYLES
   =================================== */

/* Admin Wrapper */
.iiivp-admin-wrap {
    margin: 20px 20px 0 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.iiivp-header {
    margin: 20px 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Modal Styles */
.iiivp-modal {
    display: none;
    position: fixed;
    z-index: 999999 !important;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(220, 38, 38, 0.1);
    backdrop-filter: blur(2px);
}

/* Ensure WordPress Media Modal appears above our modal */
.media-modal {
    z-index: 9999999 !important;
}

.media-modal-backdrop {
    z-index: 9999998 !important;
}

.iiivp-modal-content {
    background-color: #fff;
    margin: 2% auto;
    padding: 0;
    border-radius: 12px;
    width: 90%;
    max-width: 700px;
    box-shadow: 0 10px 40px rgba(220, 38, 38, 0.15);
    animation: modalSlideIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    max-height: 90vh;
    overflow-y: auto;
    border: 2px solid #dc2626;
}

@keyframes modalSlideIn {
    from { 
        opacity: 0; 
        transform: translateY(-30px) scale(0.95); 
    }
    to { 
        opacity: 1; 
        transform: translateY(0) scale(1); 
    }
}

.iiivp-modal-header {
    background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
    color: white;
    padding: 25px 30px;
    border-radius: 10px 10px 0 0;
    position: relative;
}

.iiivp-modal-header h2 {
    margin: 0;
    font-size: 1.5em;
    font-weight: 600;
    letter-spacing: -0.5px;
}

.iiivp-close {
    position: absolute;
    right: 25px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 26px;
    cursor: pointer;
    color: rgba(255, 255, 255, 0.8);
    transition: all 0.3s ease;
    padding: 5px;
    border-radius: 50%;
}

.iiivp-close:hover {
    color: white;
    background-color: rgba(255, 255, 255, 0.1);
}

/* Form Styles */
#project-form {
    padding: 30px;
}

.iiivp-form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

.iiivp-form-group {
    display: flex;
    flex-direction: column;
}

.iiivp-form-group label {
    font-weight: 600;
    margin-bottom: 8px;
    color: #2c3e50;
    font-size: 14px;
}

.iiivp-form-group input,
.iiivp-form-group select,
.iiivp-form-group textarea {
    padding: 14px 16px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 14px;
    transition: all 0.3s ease;
    background-color: #fff;
    font-family: inherit;
}

.iiivp-form-group input:focus,
.iiivp-form-group select:focus,
.iiivp-form-group textarea:focus {
    outline: none;
    border-color: #dc2626;
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.1);
    background-color: #fafbfc;
}

.iiivp-form-group textarea {
    resize: vertical;
    min-height: 100px;
}

/* Image Upload Styles */
.iiivp-image-upload-container {
    border: 2px dashed #cbd5e0;
    border-radius: 12px;
    padding: 25px;
    text-align: center;
    transition: all 0.3s ease;
    background-color: #f8fafc;
}

.iiivp-image-upload-container:hover {
    border-color: #dc2626;
    background-color: #fef2f2;
}

.iiivp-image-preview {
    position: relative;
    display: inline-block;
    margin-bottom: 20px;
}

.iiivp-image-preview img {
    max-width: 250px;
    max-height: 180px;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    object-fit: cover;
}

.iiivp-remove-image {
    position: absolute;
    top: -8px;
    right: -8px;
    background: #e53e3e;
    color: white;
    border: none;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(229, 62, 62, 0.3);
}

.iiivp-remove-image:hover {
    background: #c53030;
    transform: scale(1.1);
}

.iiivp-form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 15px;
    margin-top: 30px;
    padding-top: 25px;
    border-top: 1px solid #e2e8f0;
}

.iiivp-form-actions .button {
    padding: 12px 24px;
    border-radius: 8px;
    font-weight: 600;
    transition: all 0.3s ease;
}

/* Projects Container */
.iiivp-projects-container {
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    overflow: hidden;
    margin-top: 20px;
}

.iiivp-projects-header {
    background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
    color: white;
    padding: 25px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}

.iiivp-projects-header h3 {
    margin: 0;
    font-size: 1.4em;
    font-weight: 600;
    letter-spacing: -0.5px;
}

.iiivp-shortcode-info {
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(255, 255, 255, 0.15);
    padding: 10px 18px;
    border-radius: 25px;
    font-size: 14px;
    backdrop-filter: blur(10px);
}

.iiivp-shortcode-info code {
    background: rgba(255, 255, 255, 0.25);
    padding: 6px 12px;
    border-radius: 6px;
    font-family: 'SFMono-Regular', Consolas, monospace;
    font-weight: 500;
}

/* Projects Grid */
.iiivp-projects-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
    gap: 25px;
    padding: 30px;
}

/* Admin Project Cards */
.iiivp-project-card {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    overflow: hidden;
    transition: all 0.3s ease;
    position: relative;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.05);
}

.iiivp-project-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 30px rgba(220, 38, 38, 0.15);
    border-color: #dc2626;
}

.iiivp-project-image {
    position: relative;
    height: 200px;
    overflow: hidden;
}

/* Only show image container if image exists */
.iiivp-project-card:not([data-has-image]) .iiivp-project-image {
    display: none;
}

.iiivp-project-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.iiivp-project-card:hover .iiivp-project-image img {
    transform: scale(1.05);
}

.iiivp-image-overlay {
    position: absolute;
    top: 15px;
    right: 15px;
    z-index: 2;
}

.iiivp-project-content {
    padding: 25px;
}

.iiivp-project-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 20px;
}

.iiivp-project-header h4 {
    margin: 0;
    color: #2d3748;
    font-size: 1.25em;
    font-weight: 700;
    line-height: 1.3;
    flex: 1;
    margin-right: 15px;
}

.iiivp-status-no-image {
    margin-bottom: 15px;
}

.iiivp-project-actions {
    display: flex;
    gap: 8px;
}

.iiivp-btn-edit,
.iiivp-btn-delete {
    background: none;
    border: none;
    padding: 8px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
    color: #718096;
}

.iiivp-btn-edit:hover {
    background-color: #ebf8ff;
    color: #3182ce;
    transform: translateY(-1px);
}

.iiivp-btn-delete:hover {
    background-color: #fed7d7;
    color: #e53e3e;
    transform: translateY(-1px);
}

/* Project Meta */
.iiivp-project-meta {
    margin-bottom: 20px;
    background-color: #f7fafc;
    border-radius: 8px;
    padding: 15px;
}

.iiivp-meta-item {
    display: flex;
    align-items: center;
    margin-bottom: 10px;
    gap: 10px;
}

.iiivp-meta-item:last-child {
    margin-bottom: 0;
}

.iiivp-meta-icon {
    font-size: 16px;
    width: 20px;
    text-align: center;
}

.iiivp-meta-label {
    font-weight: 600;
    color: #4a5568;
    min-width: 70px;
}

.iiivp-meta-value {
    color: #2d3748;
    font-weight: 500;
}

/* Status Badges */
.iiivp-status {
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.iiivp-status-completed {
    background: linear-gradient(135deg, #48bb78, #38a169);
    color: white;
    box-shadow: 0 2px 8px rgba(72, 187, 120, 0.3);
}

.iiivp-status-inprogress {
    background: linear-gradient(135deg, #ed8936, #dd6b20);
    color: white;
    box-shadow: 0 2px 8px rgba(237, 137, 54, 0.3);
}

/* Project Description */
.iiivp-project-description {
    margin-bottom: 20px;
}

.iiivp-project-description p {
    margin: 0;
    color: #4a5568;
    line-height: 1.6;
    font-size: 14px;
}

/* Project Date */
.iiivp-project-date {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #718096;
    font-size: 13px;
    border-top: 1px solid #e2e8f0;
    padding-top: 15px;
}

.iiivp-date-icon {
    font-size: 14px;
}

/* No Projects State */
.iiivp-no-projects {
    grid-column: 1 / -1;
    text-align: center;
    padding: 80px 20px;
    color: #718096;
}

.iiivp-no-projects-icon {
    font-size: 5em;
    margin-bottom: 20px;
    opacity: 0.3;
}

.iiivp-no-projects h3 {
    margin-bottom: 15px;
    color: #4a5568;
    font-size: 1.5em;
}

.iiivp-no-projects p {
    font-size: 16px;
    color: #718096;
}

/* ===================================
   FRONTEND STYLES
   =================================== */

.iiivp-projects-frontend {
    margin: 30px 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.iiivp-projects-grid-frontend {
    display: grid;
    gap: 30px;
}

/* Grid Column Classes */
.iiivp-columns-1 {
    grid-template-columns: 1fr;
}

.iiivp-columns-2 {
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
}

.iiivp-columns-3 {
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}

.iiivp-columns-4 {
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

/* Frontend Project Cards - FORCE WHITE BACKGROUND */
.iiivp-project-card-frontend {
    background: white !important;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 4px 25px rgba(0, 0, 0, 0.08);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid #e2e8f0;
    position: relative;
    color: #1a202c !important;
}

.iiivp-project-card-frontend:hover {
    transform: translateY(-8px);
    box-shadow: 0 20px 40px rgba(220, 38, 38, 0.15);
    border-color: #dc2626;
}

.iiivp-project-image-frontend {
    position: relative;
    overflow: hidden;
    background: linear-gradient(135deg, #f7fafc 0%, #edf2f7 100%);
}

/* Dynamic height based on image presence */
.iiivp-project-card-frontend[data-has-image="true"] .iiivp-project-image-frontend {
    height: 220px;
}

.iiivp-project-card-frontend[data-has-image="false"] .iiivp-project-image-frontend,
.iiivp-project-card-frontend:not([data-has-image]) .iiivp-project-image-frontend {
    display: none;
}

.iiivp-project-image-frontend img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.4s ease;
}

.iiivp-project-card-frontend:hover .iiivp-project-image-frontend img {
    transform: scale(1.1);
}

.iiivp-image-overlay {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 2;
}

.iiivp-project-content-frontend {
    padding: 30px;
}

.iiivp-project-header-frontend {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 25px;
    gap: 15px;
}

.iiivp-project-header-frontend h3 {
    margin: 0;
    color: #1a202c;
    font-size: 1.4em;
    font-weight: 700;
    line-height: 1.3;
    flex: 1;
}

/* Frontend Status */
.iiivp-status-frontend {
    padding: 8px 16px;
    border-radius: 25px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    white-space: nowrap;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.iiivp-status-frontend.iiivp-status-completed {
    background: linear-gradient(135deg, #10b981, #059669) !important;
    color: white !important;
}

.iiivp-status-frontend.iiivp-status-inprogress {
    background: linear-gradient(135deg, #f59e0b, #d97706) !important;
    color: white !important;
}

/* Frontend Meta */
.iiivp-project-meta-frontend {
    margin-bottom: 25px;
}

.iiivp-meta-row {
    display: flex;
    align-items: center;
    padding: 15px 0;
    border-bottom: 1px solid #e2e8f0;
    gap: 15px;
}

.iiivp-meta-row:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.iiivp-meta-icon {
    color: #dc2626;
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.iiivp-meta-content {
    flex: 1;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.iiivp-meta-label {
    font-weight: 600;
    color: #4a5568;
    font-size: 14px;
}

.iiivp-meta-value {
    color: #1a202c;
    font-weight: 700;
    background: linear-gradient(135deg, #edf2f7, #e2e8f0);
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 14px;
}

/* Frontend Description */
.iiivp-project-description-frontend {
    margin-bottom: 25px;
}

.iiivp-project-description-frontend p {
    margin: 0;
    color: #4a5568;
    line-height: 1.7;
    font-size: 15px;
}

/* Frontend Footer */
.iiivp-project-footer-frontend {
    border-top: 1px solid #e2e8f0;
    padding-top: 20px;
}

.iiivp-project-date-frontend {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #718096;
    font-size: 13px;
    font-style: italic;
}

.iiivp-project-date-frontend svg {
    color: #cbd5e0;
}

/* Frontend No Projects */
.iiivp-no-projects-frontend {
    text-align: center;
    padding: 80px 20px;
    background: linear-gradient(135deg, #f7fafc 0%, #edf2f7 100%);
    border-radius: 16px;
    border: 2px dashed #cbd5e0;
}

.iiivp-no-projects-frontend p {
    color: #718096;
    font-size: 18px;
    margin: 0;
    font-weight: 500;
}

/* Style Variations */
.iiivp-style-classic .iiivp-project-card-frontend {
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.iiivp-style-minimal .iiivp-project-card-frontend {
    border-radius: 0;
    box-shadow: none;
    border: 1px solid #e2e8f0;
    border-left: 4px solid #dc2626;
}

.iiivp-style-minimal .iiivp-project-image-frontend {
    height: 180px;
}

/* Animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.iiivp-project-card-frontend {
    animation: fadeInUp 0.6s ease-out forwards;
}

.iiivp-project-card-frontend:nth-child(1) { animation-delay: 0.1s; }
.iiivp-project-card-frontend:nth-child(2) { animation-delay: 0.2s; }
.iiivp-project-card-frontend:nth-child(3) { animation-delay: 0.3s; }
.iiivp-project-card-frontend:nth-child(4) { animation-delay: 0.4s; }
.iiivp-project-card-frontend:nth-child(5) { animation-delay: 0.5s; }
.iiivp-project-card-frontend:nth-child(6) { animation-delay: 0.6s; }

/* Loading Animation */
.iiivp-loading {
    text-align: center;
    padding: 40px;
    color: #718096;
}

.iiivp-loading::before {
    content: '';
    display: inline-block;
    width: 24px;
    height: 24px;
    border: 3px solid #e2e8f0;
    border-top: 3px solid #dc2626;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-right: 15px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ===================================
   RESPONSIVE DESIGN
   =================================== */

@media (max-width: 768px) {
    .iiivp-modal-content {
        margin: 5% auto;
        width: 95%;
    }
    
    .iiivp-form-row {
        grid-template-columns: 1fr;
    }
    
    .iiivp-projects-grid {
        grid-template-columns: 1fr;
        padding: 20px;
        gap: 20px;
    }
    
    .iiivp-projects-header {
        flex-direction: column;
        text-align: center;
        padding: 20px;
    }
    
    .iiivp-shortcode-info {
        font-size: 13px;
    }
    
    .iiivp-projects-grid-frontend {
        grid-template-columns: 1fr !important;
        gap: 20px;
    }
    
    .iiivp-project-header-frontend {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }
    
    .iiivp-meta-content {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    .iiivp-meta-value {
        align-self: flex-start;
    }
    
    .iiivp-project-content-frontend {
        padding: 20px;
    }
    
    .iiivp-project-image-frontend {
        height: 180px;
    }
}

@media (max-width: 480px) {
    .iiivp-admin-wrap {
        margin-right: 0;
    }
    
    .iiivp-form-actions {
        flex-direction: column;
    }
    
    .iiivp-form-actions .button {
        width: 100%;
        justify-content: center;
    }
    
    .iiivp-project-content {
        padding: 20px;
    }
    
    .iiivp-projects-header h3 {
        font-size: 1.2em;
    }
    
    .iiivp-shortcode-info {
        padding: 8px 12px;
        font-size: 12px;
    }
}

/* ===================================
   PRINT STYLES
   =================================== */

@media print {
    .iiivp-project-card-frontend {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #ddd;
        margin-bottom: 20px;
        page-break-inside: avoid;
    }
    
    .iiivp-projects-grid-frontend {
        display: block;
    }
    
    .iiivp-status-frontend {
        background: #f0f0f0 !important;
        color: #333 !important;
        box-shadow: none;
    }
    
    .iiivp-project-actions {
        display: none;
    }
}

/* ===================================
   ACCESSIBILITY IMPROVEMENTS
   =================================== */

.iiivp-btn-edit:focus,
.iiivp-btn-delete:focus,
.iiivp-close:focus {
    outline: 2px solid #dc2626;
    outline-offset: 2px;
}

.iiivp-project-card:focus-within {
    outline: 2px solid #dc2626;
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .iiivp-project-card,
    .iiivp-project-card-frontend {
        border-width: 2px;
    }
    
    .iiivp-status {
        border: 2px solid currentColor;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .iiivp-project-card,
    .iiivp-project-card-frontend,
    .iiivp-modal-content {
        transition: none;
        animation: none;
    }
    
    .iiivp-project-card:hover,
    .iiivp-project-card-frontend:hover {
        transform: none;
    }
}

/* Dark mode support (if theme supports it) - OVERRIDE WITH RED THEME */
@media (prefers-color-scheme: dark) {
    .iiivp-projects-frontend {
        color-scheme: light !important; /* Force light scheme */
    }
    
    .iiivp-project-card-frontend {
        background: white !important; /* Force white background */
        border-color: #e2e8f0 !important;
        color: #1a202c !important; /* Force dark text */
    }
    
    .iiivp-project-header-frontend h3 {
        color: #1a202c !important; /* Force dark text */
    }
    
    .iiivp-meta-label {
        color: #4a5568 !important;
    }
    
    .iiivp-meta-value {
        background: #f8f9fa !important;
        color: #1a202c !important;
    }
    
    .iiivp-project-description-frontend p {
        color: #4a5568 !important;
    }
}

/* Tooltip styles */
.iiivp-tooltip {
    position: relative;
    cursor: help;
}

.iiivp-tooltip:hover::after {
    content: attr(title);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    white-space: nowrap;
    z-index: 1000;
}

/* Custom scrollbar for modal */
.iiivp-modal-content::-webkit-scrollbar {
    width: 6px;
}

.iiivp-modal-content::-webkit-scrollbar-track {
    background: #f1f5f9;
}

.iiivp-modal-content::-webkit-scrollbar-thumb {
    background: #cbd5e0;
    border-radius: 3px;
}

.iiivp-modal-content::-webkit-scrollbar-thumb:hover {
    background: #a0aec0;
}

/* ===================================
   ADDITIONAL FRONTEND OVERRIDES
   =================================== */

/* Ensure all frontend elements use proper colors */
.iiivp-projects-frontend * {
    box-sizing: border-box;
}

.iiivp-project-content-frontend {
    padding: 30px;
    background: white !important;
}

.iiivp-project-header-frontend h3 {
    margin: 0;
    color: #1a202c !important;
    font-size: 1.4em;
    font-weight: 700;
    line-height: 1.3;
    flex: 1;
}

.iiivp-meta-content {
    flex: 1;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.iiivp-meta-label {
    font-weight: 600;
    color: #4a5568 !important;
    font-size: 14px;
}

.iiivp-meta-value {
    color: #1a202c !important;
    font-weight: 700;
    background: #f8f9fa !important;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 14px;
}

/* Red accent for meta icons */
.iiivp-meta-icon {
    color: #dc2626 !important;
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

/* Force white background for all project elements */
.iiivp-project-card-frontend,
.iiivp-project-content-frontend,
.iiivp-project-header-frontend,
.iiivp-project-meta-frontend,
.iiivp-project-description-frontend,
.iiivp-project-footer-frontend {
    background: white !important;
    color: inherit !important;
}