/**
 * File Attachments Addon Styles
 *
 * @package Polanger_Ticket_System_Pro
 */

/* ==========================================================================
   Dropzone
   ========================================================================== */

.pgtsp-attachments-dropzone {
    border: 2px dashed #d1d5db;
    border-radius: 12px;
    padding: 40px 20px;
    text-align: center;
    background: #f9fafb;
    cursor: pointer;
    transition: all 0.3s ease;
}

.pgtsp-attachments-dropzone:hover,
.pgtsp-attachments-dropzone.pgtsp-dragover {
    border-color: #6366f1;
    background: #eef2ff;
}

.pgtsp-attachments-dropzone.pgtsp-dragover {
    transform: scale(1.01);
}

.pgtsp-dropzone-content {
    pointer-events: none;
}

.pgtsp-dropzone-content .dashicons {
    font-size: 48px;
    width: 48px;
    height: 48px;
    color: #9ca3af;
    margin-bottom: 12px;
}

.pgtsp-attachments-dropzone:hover .dashicons,
.pgtsp-attachments-dropzone.pgtsp-dragover .dashicons {
    color: #6366f1;
}

.pgtsp-dropzone-content p {
    margin: 0 0 8px;
    font-size: 15px;
    font-weight: 500;
    color: #374151;
}

.pgtsp-dropzone-hint {
    font-size: 12px;
    color: #9ca3af;
}

/* ==========================================================================
   Attachments Preview (New Ticket / Reply)
   ========================================================================== */

.pgtsp-attachments-preview,
.pgtsp-reply-attachments-preview,
#pgtsp-admin-attachments-preview {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 16px;
}

.pgtsp-attachment-preview-item {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    max-width: 280px;
    transition: all 0.2s ease;
}

.pgtsp-attachment-preview-item:hover {
    border-color: #6366f1;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.1);
}

.pgtsp-attachment-preview-item.pgtsp-uploading {
    opacity: 0.7;
}

.pgtsp-attachment-preview-thumb {
    width: 48px;
    height: 48px;
    border-radius: 6px;
    overflow: hidden;
    flex-shrink: 0;
    background: #f3f4f6;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pgtsp-attachment-preview-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.pgtsp-attachment-preview-thumb .dashicons {
    font-size: 24px;
    width: 24px;
    height: 24px;
    color: #6b7280;
}

.pgtsp-attachment-preview-info {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.pgtsp-attachment-preview-name {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: #374151;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pgtsp-attachment-preview-size {
    display: block;
    font-size: 11px;
    color: #9ca3af;
    margin-top: 2px;
}

.pgtsp-attachment-preview-remove {
    position: absolute;
    top: -6px;
    right: -6px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #ef4444;
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    line-height: 1;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.pgtsp-attachment-preview-item:hover .pgtsp-attachment-preview-remove {
    opacity: 1;
}

.pgtsp-attachment-preview-remove:hover {
    background: #dc2626;
}

.pgtsp-attachment-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: #e5e7eb;
    border-radius: 0 0 8px 8px;
    overflow: hidden;
}

.pgtsp-attachment-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #6366f1, #8b5cf6);
    width: 0;
    transition: width 0.3s ease;
}

/* ==========================================================================
   Reply Form Attachment Button
   ========================================================================== */

.pgtsp-attach-btn,
.pgtsp-admin-attach-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 12px;
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    color: #6b7280;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 13px;
}

.pgtsp-attach-btn:hover,
.pgtsp-admin-attach-btn:hover {
    background: #e5e7eb;
    color: #374151;
    border-color: #d1d5db;
}

.pgtsp-attach-btn .dashicons,
.pgtsp-admin-attach-btn .dashicons {
    font-size: 18px;
    width: 18px;
    height: 18px;
}

.pgtsp-admin-attach-btn {
    background: #fff;
    border-color: #d1d5db;
}

.pgtsp-admin-attach-btn:hover {
    background: #f9fafb;
    border-color: #6366f1;
    color: #6366f1;
}

/* ==========================================================================
   Message Attachments Display
   ========================================================================== */

.pgtsp-message-attachments {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid #e5e7eb;
}

.pgtsp-attachments-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
}

.pgtsp-attachments-label .dashicons {
    font-size: 14px;
    width: 14px;
    height: 14px;
}

.pgtsp-attachments-list {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

/* Image Attachments */
.pgtsp-attachment-item.pgtsp-attachment-image {
    width: 100px;
    height: 100px;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #e5e7eb;
    transition: all 0.2s ease;
}

.pgtsp-attachment-item.pgtsp-attachment-image:hover {
    border-color: #6366f1;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.15);
    transform: translateY(-2px);
}

.pgtsp-attachment-thumb {
    display: block;
    width: 100%;
    height: 100%;
}

.pgtsp-attachment-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* File Attachments */
.pgtsp-attachment-item.pgtsp-attachment-file {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.pgtsp-attachment-item.pgtsp-attachment-file:hover {
    border-color: #6366f1;
    background: #fff;
}

.pgtsp-attachment-file-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    text-decoration: none;
    color: inherit;
}

.pgtsp-attachment-file-link .dashicons {
    font-size: 24px;
    width: 24px;
    height: 24px;
    color: #6366f1;
}

.pgtsp-attachment-name {
    font-size: 13px;
    font-weight: 500;
    color: #374151;
    max-width: 150px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pgtsp-attachment-size {
    font-size: 11px;
    color: #9ca3af;
    margin-left: auto;
}

/* ==========================================================================
   Reply Attachments Preview (Compact)
   ========================================================================== */

.pgtsp-reply-attachments-preview {
    margin-bottom: 12px;
}

.pgtsp-reply-attachments-preview:empty {
    display: none;
}

.pgtsp-reply-attachments-preview .pgtsp-attachment-preview-item {
    padding: 8px 10px;
}

.pgtsp-reply-attachments-preview .pgtsp-attachment-preview-thumb {
    width: 36px;
    height: 36px;
}

/* ==========================================================================
   Admin Attachments Preview
   ========================================================================== */

#pgtsp-admin-attachments-preview {
    margin-top: 12px;
    padding: 12px;
    background: #f9fafb;
    border-radius: 8px;
}

#pgtsp-admin-attachments-preview:empty {
    display: none;
    padding: 0;
    margin: 0;
}

/* ==========================================================================
   Addons Page Styles
   ========================================================================== */

.pgtsp-addons-wrap {
    max-width: 1400px;
}

.pgtsp-page-header {
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    margin: -20px -20px 30px -20px;
    padding: 40px;
    color: #fff;
}

.pgtsp-page-header h1 {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 0 0 8px;
    font-size: 28px;
    font-weight: 600;
    color: #fff;
}

.pgtsp-page-header h1 .dashicons {
    font-size: 32px;
    width: 32px;
    height: 32px;
}

.pgtsp-page-header p {
    margin: 0;
    font-size: 15px;
    opacity: 0.9;
}

.pgtsp-addons-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 24px;
    padding: 0 20px 40px;
}

.pgtsp-addon-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    overflow: hidden;
    transition: all 0.3s ease;
}

.pgtsp-addon-card:hover {
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
    transform: translateY(-2px);
}

.pgtsp-addon-card.pgtsp-addon-active {
    border-color: #10b981;
}

.pgtsp-addon-card.pgtsp-addon-coming-soon {
    opacity: 0.7;
}

.pgtsp-addon-header {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 20px;
    background: #f9fafb;
    border-bottom: 1px solid #e5e7eb;
}

.pgtsp-addon-active .pgtsp-addon-header {
    background: linear-gradient(135deg, #ecfdf5 0%, #d1fae5 100%);
    border-bottom-color: #a7f3d0;
}

.pgtsp-addon-icon {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.pgtsp-addon-icon .dashicons {
    font-size: 24px;
    width: 24px;
    height: 24px;
    color: #fff;
}

.pgtsp-addon-info {
    flex: 1;
}

.pgtsp-addon-info h3 {
    margin: 0 0 4px;
    font-size: 16px;
    font-weight: 600;
    color: #1f2937;
}

.pgtsp-addon-version {
    font-size: 12px;
    color: #9ca3af;
}

.pgtsp-addon-badge {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.pgtsp-badge-active {
    background: #10b981;
    color: #fff;
}

.pgtsp-badge-coming-soon {
    background: #f59e0b;
    color: #fff;
}

.pgtsp-addon-body {
    padding: 20px;
}

.pgtsp-addon-body p {
    margin: 0;
    font-size: 14px;
    color: #6b7280;
    line-height: 1.6;
}

.pgtsp-addon-footer {
    padding: 16px 20px;
    background: #f9fafb;
    border-top: 1px solid #e5e7eb;
}

.pgtsp-addon-footer .pgtsp-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.2s ease;
}

.pgtsp-addon-footer .pgtsp-btn .dashicons {
    font-size: 16px;
    width: 16px;
    height: 16px;
}

.pgtsp-btn-activate {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: #fff;
}

.pgtsp-btn-activate:hover {
    background: linear-gradient(135deg, #059669 0%, #047857 100%);
    transform: translateY(-1px);
}

.pgtsp-btn-deactivate {
    background: #fff;
    color: #ef4444;
    border: 1px solid #fecaca;
}

.pgtsp-btn-deactivate:hover {
    background: #fef2f2;
    border-color: #ef4444;
}

.pgtsp-btn-disabled {
    background: #e5e7eb;
    color: #9ca3af;
    cursor: not-allowed;
}

.pgtsp-btn.pgtsp-loading {
    opacity: 0.7;
    pointer-events: none;
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 768px) {
    .pgtsp-attachments-dropzone {
        padding: 30px 15px;
    }

    .pgtsp-dropzone-content .dashicons {
        font-size: 36px;
        width: 36px;
        height: 36px;
    }

    .pgtsp-attachment-preview-item {
        max-width: 100%;
    }

    .pgtsp-attachment-item.pgtsp-attachment-image {
        width: 80px;
        height: 80px;
    }

    .pgtsp-addons-grid {
        grid-template-columns: 1fr;
        padding: 0 10px 30px;
    }

    .pgtsp-page-header {
        padding: 30px 20px;
        margin: -10px -10px 20px -10px;
    }
}

/* ==========================================================================
   Message Attachments Gallery
   ========================================================================== */

.pgtsp-message-attachments {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid rgba(0, 0, 0, 0.08);
}

.pgtsp-attachments-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
}

.pgtsp-attachments-label .dashicons {
    font-size: 14px;
    width: 14px;
    height: 14px;
    color: #6b7280;
}

/* Admin panel - Support messages (purple background) need white text */
.pgtsp-message-support .pgtsp-message-attachments {
    border-top-color: rgba(255, 255, 255, 0.15);
}

.pgtsp-message-support .pgtsp-attachments-label,
.pgtsp-message-support .pgtsp-attachments-label .dashicons {
    color: #fff !important;
}

/* Admin panel ticket detail - Staff messages with gradient background */
.pgtsp-ticket-detail .pgtsp-message-support .pgtsp-attachments-label,
.pgtsp-ticket-detail .pgtsp-message-support .pgtsp-attachments-label .dashicons {
    color: #fff !important;
}

/* Frontend - Admin messages (blue background) need darker text */
.pgtsp-admin-message .pgtsp-message-attachments {
    border-top-color: rgba(0, 0, 0, 0.1);
}

.pgtsp-admin-message .pgtsp-attachments-label,
.pgtsp-admin-message .pgtsp-attachments-label .dashicons {
    color: #4b5563;
}

.pgtsp-attachments-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 10px;
}

.pgtsp-attachment-item {
    border-radius: 8px;
    overflow: hidden;
    transition: all 0.2s ease;
}

.pgtsp-attachment-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* Image attachments */
.pgtsp-attachment-item.pgtsp-attachment-image {
    aspect-ratio: 1;
    background: #f3f4f6;
}

.pgtsp-attachment-thumb {
    display: block;
    width: 100%;
    height: 100%;
}

.pgtsp-attachment-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 8px;
}

/* File attachments */
.pgtsp-attachment-item.pgtsp-attachment-file {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
}

.pgtsp-attachment-file-link {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 16px 12px;
    text-decoration: none;
    color: inherit;
    text-align: center;
    min-height: 100px;
}

.pgtsp-attachment-file-link .dashicons {
    font-size: 28px;
    width: 28px;
    height: 28px;
    color: #6366f1;
    margin-bottom: 8px;
}

.pgtsp-attachment-name {
    font-size: 11px;
    font-weight: 500;
    color: #374151;
    word-break: break-all;
    line-height: 1.3;
    max-height: 2.6em;
    overflow: hidden;
}

.pgtsp-attachment-size {
    font-size: 10px;
    color: #9ca3af;
    margin-top: 4px;
}

/* ==========================================================================
   Admin Sidebar Attachments
   ========================================================================== */

.pgtsp-attachments-card .pgtsp-card-header h3 {
    display: flex;
    align-items: center;
    gap: 8px;
}

.pgtsp-attachments-card .pgtsp-card-header h3 .dashicons {
    color: #6366f1;
}

.pgtsp-attachment-count {
    background: #6366f1;
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
    margin-left: auto;
}

.pgtsp-sidebar-attachments {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    padding: 12px !important;
}

.pgtsp-sidebar-attachment-item {
    border-radius: 6px;
    overflow: hidden;
}

.pgtsp-sidebar-thumb {
    display: block;
    aspect-ratio: 1;
    background: #f3f4f6;
}

.pgtsp-sidebar-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 6px;
    transition: transform 0.2s ease;
}

.pgtsp-sidebar-thumb:hover img {
    transform: scale(1.05);
}

.pgtsp-sidebar-file {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 10px 6px;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    text-decoration: none;
    color: inherit;
    min-height: 70px;
    transition: all 0.2s ease;
}

.pgtsp-sidebar-file:hover {
    background: #eef2ff;
    border-color: #6366f1;
}

.pgtsp-sidebar-file .dashicons {
    font-size: 20px;
    width: 20px;
    height: 20px;
    color: #6366f1;
    margin-bottom: 4px;
}

.pgtsp-sidebar-file-name {
    font-size: 9px;
    color: #6b7280;
    text-align: center;
    word-break: break-all;
    line-height: 1.2;
    max-height: 2.4em;
    overflow: hidden;
}

/* ==========================================================================
   Hidden Input for Attachment IDs
   ========================================================================== */

#pgtsp-attachment-ids,
#pgtsp-reply-attachment-ids,
#pgtsp-admin-attachment-ids {
    display: none;
}
