/**
 * Gallery Management System Styles
 * File: tgall-add.css
 */

/* Container Styles */
.tgall-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    position: relative;
}

/* Add Button Styles */
.tgall-add-button {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    background-color: #2271b1;
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.3s ease;
}

.tgall-add-button:hover {
    background-color: #135e96;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.tgall-add-button:focus {
    outline: 2px solid #135e96;
    outline-offset: 2px;
}

/* Modal Styles */
.tgall-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 99999;
    padding: 20px;
}

.tgall-modal-content {
    background-color: #fff;
    max-width: 800px;
    margin: 40px auto;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    max-height: calc(100vh - 80px);
    overflow-y: auto;
}

.tgall-modal-header {
    padding: 20px;
    border-bottom: 1px solid #e5e5e5;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: #f8f9fa;
    border-radius: 8px 8px 0 0;
}

.tgall-modal-header h2 {
    margin: 0;
    font-size: 24px;
    color: #1d2327;
    font-weight: 500;
}

.tgall-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #666;
    padding: 8px;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.tgall-close:hover {
    background-color: #f0f0f1;
    color: #1d2327;
}

.tgall-modal-body {
    padding: 20px;
}

/* Form Styles */
.tgall-form-group {
    margin-bottom: 20px;
}

.tgall-form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #1d2327;
}

.tgall-form-group input[type="text"],
.tgall-form-group textarea,
.tgall-form-group select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 16px;
    transition: all 0.2s ease;
}

.tgall-form-group input[type="text"]:focus,
.tgall-form-group textarea:focus,
.tgall-form-group select:focus {
    border-color: #2271b1;
    box-shadow: 0 0 0 1px #2271b1;
    outline: none;
}

.tgall-form-group input.has-error,
.tgall-form-group textarea.has-error,
.tgall-form-group select.has-error {
    border-color: #d63638;
}

.field-error {
    color: #d63638;
    font-size: 14px;
    margin-top: 4px;
}

/* Gallery Container Styles */
.gallery-container {
    border: 2px dashed #ccc;
    padding: 20px;
    border-radius: 4px;
    background-color: #f9f9f9;
    transition: all 0.2s ease;
}

.gallery-container:hover {
    border-color: #2271b1;
    background-color: #f0f7fc;
}

.gallery-preview {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 10px;
    margin-bottom: 15px;
}

.gallery-item {
    position: relative;
    border: 1px solid #ddd;
    border-radius: 4px;
    overflow: hidden;
    cursor: move;
    transition: all 0.2s ease;
}

.gallery-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.gallery-item img {
    width: 100%;
    height: 120px;
    object-fit: cover;
    display: block;
}

.gallery-item .remove-image {
    position: absolute;
    top: 5px;
    right: 5px;
    background-color: rgba(255, 255, 255, 0.9);
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #dc3232;
    transition: all 0.2s ease;
}

.gallery-item .remove-image:hover {
    background-color: #dc3232;
    color: #fff;
}

.gallery-placeholder {
    border: 2px dashed #2271b1;
    background-color: rgba(34, 113, 177, 0.1);
    border-radius: 4px;
}

.add-images {
    width: 100%;
    padding: 12px;
    background-color: #fff;
    border: 1px dashed #2271b1;
    border-radius: 4px;
    color: #2271b1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s ease;
}

.add-images:hover {
    background-color: #f0f7fc;
    border-style: solid;
}

/* Category Container Styles */
.category-container {
    display: flex;
    gap: 10px;
    align-items: center;
}

.category-container select {
    flex: 1;
}

.add-category {
    background-color: #2271b1;
    color: #fff;
    border: none;
    border-radius: 4px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.add-category:hover {
    background-color: #135e96;
    transform: translateY(-1px);
}

/* Form Actions */
.tgall-form-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #e5e5e5;
}

.tgall-submit,
.tgall-cancel {
    padding: 10px 20px;
    border-radius: 4px;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.tgall-submit {
    background-color: #2271b1;
    color: #fff;
    border: none;
}

.tgall-submit:hover {
    background-color: #135e96;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.tgall-cancel {
    background-color: #f0f0f1;
    border: 1px solid #c3c4c7;
    color: #1d2327;
}

.tgall-cancel:hover {
    background-color: #e5e5e5;
}

/* Loading Overlay */
.tgall-loading-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    z-index: 999999;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    backdrop-filter: blur(5px);
}

.tgall-loading-overlay.active {
    display: flex;
}

/* Loading Animation */
.tgall-loading-spinner {
    width: 80px;
    height: 80px;
    position: relative;
    margin-bottom: 20px;
}

.tgall-loading-spinner div {
    position: absolute;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #2271b1;
    animation: tgall-spinner 1.2s linear infinite;
}

.tgall-loading-spinner div:nth-child(1) {
    top: 8px;
    left: 8px;
    animation-delay: 0s;
}

.tgall-loading-spinner div:nth-child(2) {
    top: 8px;
    left: 32px;
    animation-delay: -0.4s;
}

.tgall-loading-spinner div:nth-child(3) {
    top: 8px;
    left: 56px;
    animation-delay: -0.8s;
}

.tgall-loading-spinner div:nth-child(4) {
    top: 32px;
    left: 8px;
    animation-delay: -0.4s;
}

.tgall-loading-spinner div:nth-child(5) {
    top: 32px;
    left: 32px;
    animation-delay: -0.8s;
}

.tgall-loading-spinner div:nth-child(6) {
    top: 32px;
    left: 56px;
    animation-delay: -1.2s;
}

.tgall-loading-spinner div:nth-child(7) {
    top: 56px;
    left: 8px;
    animation-delay: -0.8s;
}

.tgall-loading-spinner div:nth-child(8) {
    top: 56px;
    left: 32px;
    animation-delay: -1.2s;
}

.tgall-loading-spinner div:nth-child(9) {
    top: 56px;
    left: 56px;
    animation-delay: -1.6s;
}

@keyframes tgall-spinner {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.3;
    }
}

/* Loading Text */
.tgall-loading-text {
    font-size: 18px;
    color: #2271b1;
    font-weight: 500;
    text-align: center;
    margin-top: 15px;
}

/* Loading Progress */
.tgall-loading-progress {
    width: 200px;
    height: 4px;
    background: #e2e8f0;
    border-radius: 2px;
    margin-top: 15px;
    overflow: hidden;
}

.tgall-loading-progress-bar {
    width: 0;
    height: 100%;
    background: #2271b1;
    border-radius: 2px;
    transition: width 0.3s ease;
    animation: progress 2s ease infinite;
}

@keyframes progress {
    0% {
        width: 0;
    }
    50% {
        width: 70%;
    }
    100% {
        width: 100%;
    }
}

/* Datepicker Customization */
.ui-datepicker {
    background-color: #fff;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    font-size: 14px;
}

.ui-datepicker-header {
    background-color: #2271b1;
    color: #fff;
    padding: 5px;
    border-radius: 4px 4px 0 0;
}

.ui-datepicker-title {
    text-align: center;
    padding: 5px;
    font-weight: bold;
}

.ui-datepicker-prev,
.ui-datepicker-next {
    cursor: pointer;
    padding: 5px;
    color: #fff;
}

.ui-datepicker-calendar {
    background-color: #fff;
}

.ui-datepicker-calendar th {
    padding: 5px;
    text-align: center;
    font-weight: bold;
    color: #1d2327;
}

.ui-datepicker-calendar td {
    padding: 2px;
}

.ui-datepicker-calendar td a {
    display: block;
    padding: 5px;
    text-align: center;
    text-decoration: none;
    color: #1d2327;
    border-radius: 4px;
}

.ui-datepicker-calendar td a:hover {
    background-color: #f0f7fc;
}

.ui-datepicker-calendar .ui-state-active {
    background-color: #2271b1;
    color: #fff;
}

/* Alerts */
.tgall-alert {
    padding: 10px 15px;
    border-radius: 4px;
    margin-bottom: 10px;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.tgall-alert-success {
    background-color: #e8f5e9;
    color: #1e4620;
    border: 1px solid #c8e6c9;
}

.tgall-alert-error {
    background-color: #fdecea;
    color: #811c15;
    border: 1px solid #fdccc8;
}

/* Responsive Design */
@media screen and (max-width: 768px) {
    .tgall-modal-content {
        margin: 10px;
    }

    .tgall-modal-header h2 {
        font-size: 20px;
    }

    .gallery-preview {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    }

    .gallery-item img {
        height: 100px;
    }

    .tgall-form-actions {
        flex-direction: column;
        gap: 10px;
    }

    .tgall-submit,
    .tgall-cancel {
        width: 100%;
    }

    .category-container {
        flex-direction: column;
    }

    .add-category {
        width: 100%;
        height: 40px;
    }

    .tgall-loading-text {
        font-size: 16px;
        padding: 0 20px;
        text-align: center;
    }

    .tgall-loading-progress {
        width: 80%;
        max-width: 200px;
    }
}

@media screen and (max-width: 480px) {
    .tgall-modal {
        padding: 10px;
    }

    .tgall-modal-content {
        margin: 0;
    }

    .tgall-modal-header {
        padding: 15px;
    }

    .tgall-modal-body {
        padding: 15px;
    }

    .gallery-preview {
        grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    }

    .gallery-item img {
        height: 80px;
    }

    .tgall-form-group label {
        font-size: 14px;
    }

    .tgall-loading-spinner {
        width: 60px;
        height: 60px;
    }

    .tgall-loading-spinner div {
        width: 12px;
        height: 12px;
    }
}

/* Accessibility Focus Styles */
*:focus-visible {
    outline: 2px solid #2271b1;
    outline-offset: 2px;
}

/* Screen Reader Only Class */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Custom Scrollbar */
.tgall-modal-content {
    scrollbar-width: thin;
    scrollbar-color: #2271b1 #f0f0f1;
}

.tgall-modal-content::-webkit-scrollbar {
    width: 8px;
}

.tgall-modal-content::-webkit-scrollbar-track {
    background: #f0f0f1;
}

.tgall-modal-content::-webkit-scrollbar-thumb {
    background-color: #2271b1;
    border-radius: 4px;
    border: 2px solid #f0f0f1;
}

/* Drag and Drop Interactions */
.gallery-item.ui-sortable-helper {
    transform: scale(1.05);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.gallery-placeholder {
    border: 2px dashed #2271b1;
    background-color: rgba(34, 113, 177, 0.1);
    border-radius: 4px;
    visibility: visible !important;
}

/* Form Validation Styles */
.tgall-form-group input:required:invalid,
.tgall-form-group select:required:invalid {
    border-color: #dc3232;
}

.tgall-form-group input:required:valid,
.tgall-form-group select:required:valid {
    border-color: #46b450;
}

/* Button States */
.tgall-submit:disabled,
.tgall-cancel:disabled,
.add-category:disabled,
.add-images:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

/* Modal Animation */
@keyframes modalFadeIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.tgall-modal-content {
    animation: modalFadeIn 0.3s ease-out;
}

/* Loading Animation Enhancement */
@keyframes pulse {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
    100% {
        transform: scale(1);
    }
}

.tgall-loading-text {
    animation: pulse 2s infinite;
}

/* Print Styles */
@media print {
    .tgall-modal,
    .tgall-loading-overlay {
        display: none !important;
    }
}


/* Featured Image Styles */
.gallery-item.is-featured {
    position: relative;
    border: 2px solid #2271b1;
    box-shadow: 0 2px 4px rgba(34, 113, 177, 0.2);
}

.featured-badge {
    position: absolute;
    top: 5px;
    left: 5px;
    background-color: #2271b1;
    color: #fff;
    padding: 2px 8px;
    font-size: 12px;
    border-radius: 3px;
    z-index: 1;
}

/* ปรับปรุง Gallery Item Styles */
.gallery-item {
    transition: all 0.3s ease;
}

.gallery-item.is-featured:hover {
    border-color: #135e96;
    box-shadow: 0 4px 8px rgba(19, 94, 150, 0.3);
}

/* Ensure featured badge stays visible during drag */
.gallery-item.ui-sortable-helper .featured-badge {
    display: block;
}