/* photo-share.css */

/* Reset و تنظیمات پایه */
.photo-share-gallery * {
    box-sizing: border-box;
}

/* متغیرهای CSS */
:root {
    --ps-primary-color: #007cba;
    --ps-secondary-color: #005a87;
    --ps-success-color: #28a745;
    --ps-danger-color: #dc3545;
    --ps-warning-color: #ffc107;
    --ps-info-color: #17a2b8;
    --ps-light-color: #f8f9fa;
    --ps-dark-color: #343a40;
    --ps-border-radius: 12px;
    --ps-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    --ps-shadow-hover: 0 8px 15px rgba(0, 0, 0, 0.2);
    --ps-transition: all 0.3s ease;
}

/* تنظیمات کلی */
.photo-share-gallery {
    font-family: 'Vazir', 'Tahoma', sans-serif;
    direction: rtl;
    text-align: right;
}

/* Grid Layout */
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 25px;
    padding: 20px 0;
}

/* Gallery Item */
.gallery-item {
    background: #ffffff;
    border-radius: var(--ps-border-radius);
    overflow: hidden;
    box-shadow: var(--ps-shadow);
    transition: var(--ps-transition);
    position: relative;
}

.gallery-item:hover {
    transform: translateY(-8px);
    box-shadow: var(--ps-shadow-hover);
}

.gallery-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(45deg, transparent 49%, rgba(255,255,255,0.1) 50%, transparent 51%);
    opacity: 0;
    transition: var(--ps-transition);
    z-index: 1;
    pointer-events: none;
}

.gallery-item:hover::before {
    opacity: 1;
}

/* Gallery Image */
.gallery-image {
    position: relative;
    height: 220px;
    overflow: hidden;
    background: var(--ps-light-color);
}

.gallery-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    cursor: pointer;
    transition: var(--ps-transition);
    filter: brightness(1);
}

.gallery-image img:hover {
    transform: scale(1.08);
    filter: brightness(1.1);
}

.gallery-image img.lazy {
    opacity: 0;
    transition: opacity 0.3s ease;
}

.gallery-image img.lazy.loaded {
    opacity: 1;
}

/* Gallery Info */
.gallery-info {
    padding: 20px;
    background: #ffffff;
}

.gallery-info h4 {
    margin: 0 0 12px 0;
    color: var(--ps-dark-color);
    font-size: 18px;
    font-weight: 700;
    line-height: 1.4;
}

.gallery-date {
    display: inline-flex;
    align-items: center;
    margin: 0 0 10px 0;
    color: #6c757d;
    font-size: 14px;
    background: var(--ps-light-color);
    padding: 6px 12px;
    border-radius: 20px;
    font-weight: 500;
}

.gallery-date::before {
    content: '📅';
    margin-left: 8px;
}

.gallery-notes {
    margin: 0 0 12px 0;
    color: #555;
    font-size: 14px;
    font-style: italic;
    background: #e8f4fd;
    padding: 12px;
    border-radius: 8px;
    border-right: 4px solid var(--ps-primary-color);
    line-height: 1.5;
}

.gallery-notes::before {
    content: '📝';
    margin-left: 8px;
}

.gallery-size {
    margin: 0;
    color: #888;
    font-size: 12px;
    display: inline-flex;
    align-items: center;
    background: #f1f3f4;
    padding: 4px 8px;
    border-radius: 12px;
    font-weight: 500;
}

.gallery-size::before {
    content: '💾';
    margin-left: 6px;
}

/* Gallery Actions */
.gallery-actions {
    padding: 0 20px 20px;
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.delete-btn {
    background: linear-gradient(135deg, var(--ps-danger-color), #c82333);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 25px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: var(--ps-transition);
    box-shadow: 0 2px 4px rgba(220, 53, 69, 0.3);
    position: relative;
    overflow: hidden;
}

.delete-btn::before {
    content: '🗑️';
    margin-left: 8px;
}

.delete-btn:hover {
    background: linear-gradient(135deg, #c82333, #a71e2a);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(220, 53, 69, 0.4);
}

.delete-btn:active {
    transform: translateY(0);
}

.delete-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* No Photos State */
.no-photos {
    text-align: center;
    padding: 60px 20px;
    color: #6c757d;
    background: linear-gradient(135deg, #f8f9fa, #e9ecef);
    border-radius: var(--ps-border-radius);
    border: 2px dashed #dee2e6;
}

.no-photos::before {
    content: '📷';
    font-size: 48px;
    display: block;
    margin-bottom: 20px;
    opacity: 0.5;
}

.no-photos p {
    font-size: 18px;
    margin: 0;
    font-weight: 500;
}

/* Modal Styles */
.gallery-modal {
    display: none;
    position: fixed;
    z-index: 10000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    backdrop-filter: blur(5px);
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.gallery-modal-content {
    position: relative;
    max-width: 95%;
    max-height: 95%;
    margin: auto;
    top: 50%;
    transform: translateY(-50%);
    text-align: center;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        transform: translateY(-50%) scale(0.8);
        opacity: 0;
    }
    to {
        transform: translateY(-50%) scale(1);
        opacity: 1;
    }
}

.gallery-modal-content img {
    max-width: 100%;
    max-height: 70vh;
    border-radius: 12px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    transition: transform 0.3s ease;
    cursor: grab;
}

.gallery-modal-content img:active {
    cursor: grabbing;
}

.gallery-close {
    position: absolute;
    top: 20px;
    right: 30px;
    color: #ffffff;
    font-size: 42px;
    font-weight: bold;
    cursor: pointer;
    z-index: 10001;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--ps-transition);
    backdrop-filter: blur(10px);
}

.gallery-close:hover {
    background: rgba(220, 53, 69, 0.8);
    transform: scale(1.1);
}

.gallery-modal-info {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.95), rgba(248, 249, 250, 0.95));
    padding: 25px;
    margin-top: 25px;
    border-radius: 12px;
    color: var(--ps-dark-color);
    backdrop-filter: blur(10px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
    text-align: right;
    direction: rtl;
}

.gallery-modal-info h3 {
    margin: 0 0 15px 0;
    font-size: 20px;
    font-weight: 700;
    color: var(--ps-primary-color);
}

.gallery-modal-info p {
    margin: 8px 0;
    line-height: 1.6;
}

.gallery-modal-controls {
    margin-top: 25px;
    display: flex;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap;
}

.gallery-modal-controls button {
    background: linear-gradient(135deg, var(--ps-primary-color), var(--ps-secondary-color));
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 25px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: var(--ps-transition);
    box-shadow: 0 4px 8px rgba(0, 124, 186, 0.3);
    min-width: 120px;
}

.gallery-modal-controls button:hover {
    background: linear-gradient(135deg, var(--ps-secondary-color), #004068);
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 124, 186, 0.4);
}

.gallery-modal-controls button:active {
    transform: translateY(0);
}

/* Notification System */
.photo-share-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 15px 20px;
    border-radius: 8px;
    color: white;
    font-weight: 600;
    z-index: 10000;
    transform: translateX(400px);
    opacity: 0;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    backdrop-filter: blur(10px);
}

.photo-share-notification.show {
    transform: translateX(0);
    opacity: 1;
}

.photo-share-notification.success {
    background: linear-gradient(135deg, var(--ps-success-color), #218838);
}

.photo-share-notification.error {
    background: linear-gradient(135deg, var(--ps-danger-color), #c82333);
}

.photo-share-notification.info {
    background: linear-gradient(135deg, var(--ps-info-color), #138496);
}

.photo-share-notification.warning {
    background: linear-gradient(135deg, var(--ps-warning-color), #e0a800);
    color: var(--ps-dark-color);
}

/* Body lock when modal is open */
body.modal-open {
    overflow: hidden;
}

/* Loading Animation */
.gallery-loading {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 40px;
}

.gallery-loading::after {
    content: '';
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid var(--ps-primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Responsive Design */
@media (max-width: 1200px) {
    .gallery-grid {
        grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
        gap: 20px;
    }
}

@media (max-width: 768px) {
    .gallery-grid {
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
        gap: 15px;
        padding: 15px 10px;
    }
    
    .gallery-image {
        height: 200px;
    }
    
    .gallery-info {
        padding: 15px;
    }
    
    .gallery-actions {
        padding: 0 15px 15px;
        justify-content: center;
    }
    
    .gallery-modal-content {
        max-width: 98%;
        margin: 10px auto;
    }
    
    .gallery-close {
        top: 15px;
        right: 15px;
        width: 40px;
        height: 40px;
        font-size: 30px;
    }
    
    .gallery-modal-controls {
        flex-direction: column;
        align-items: center;
        gap: 10px;
    }
    
    .gallery-modal-controls button {
        width: 200px;
        margin: 0;
    }
    
    .photo-share-notification {
        right: 10px;
        left: 10px;
        transform: translateY(-100px);
    }
    
    .photo-share-notification.show {
        transform: translateY(0);
    }
}

@media (max-width: 480px) {
    .gallery-grid {
        grid-template-columns: 1fr;
        gap: 10px;
        padding: 10px 5px;
    }
    
    .gallery-item {
        margin: 0 5px;
    }
    
    .gallery-image {
        height: 180px;
    }
    
    .gallery-info h4 {
        font-size: 16px;
    }
    
    .gallery-modal-info {
        padding: 20px 15px;
        margin-top: 20px;
    }
    
    .gallery-modal-controls button {
        padding: 10px 20px;
        font-size: 13px;
        width: 150px;
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    :root {
        --ps-light-color: #2d3748;
        --ps-dark-color: #f7fafc;
    }
    
    .gallery-item {
        background: #2d3748;
        color: #f7fafc;
    }
    
    .gallery-info {
        background: #2d3748;
    }
    
    .gallery-notes {
        background: #4a5568;
        color: #e2e8f0;
    }
    
    .gallery-size {
        background: #4a5568;
        color: #e2e8f0;
    }
    
    .no-photos {
        background: linear-gradient(135deg, #2d3748, #4a5568);
        color: #e2e8f0;
        border-color: #4a5568;
    }
}

/* High DPI Display Support */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .gallery-image img {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
}

/* Print Styles */
@media print {
    .gallery-modal,
    .gallery-actions,
    .photo-share-notification {
        display: none !important;
    }
    
    .gallery-grid {
        display: block;
    }
    
    .gallery-item {
        break-inside: avoid;
        margin-bottom: 20px;
        box-shadow: none;
        border: 1px solid #ddd;
    }
}

/* Accessibility Improvements */
.gallery-item:focus-within {
    outline: 3px solid var(--ps-primary-color);
    outline-offset: 2px;
}

.delete-btn:focus,
.gallery-modal-controls button:focus {
    outline: 3px solid #ffffff;
    outline-offset: 2px;
}

/* Animation for gallery items appearing */
.gallery-item {
    animation: fadeInUp 0.6s ease forwards;
    opacity: 0;
    transform: translateY(30px);
}

.gallery-item:nth-child(1) { animation-delay: 0.1s; }
.gallery-item:nth-child(2) { animation-delay: 0.2s; }
.gallery-item:nth-child(3) { animation-delay: 0.3s; }
.gallery-item:nth-child(4) { animation-delay: 0.4s; }
.gallery-item:nth-child(5) { animation-delay: 0.5s; }
.gallery-item:nth-child(6) { animation-delay: 0.6s; }

@keyframes fadeInUp {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}