@tailwind base;
@tailwind components;
@tailwind utilities;

* {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    -webkit-tap-highlight-color: transparent;
    box-sizing: border-box;
}

html, body {
    overflow-x: hidden;
    max-width: 100%;
    touch-action: manipulation;
}

a, button, [role="button"] {
    touch-action: manipulation;
}

input, textarea, select {
    font-size: 16px;
}

@supports (padding: max(0px)) {
    body {
        padding-left: max(0px, env(safe-area-inset-left));
        padding-right: max(0px, env(safe-area-inset-right));
    }
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Sarabun', sans-serif;
}

.line-clamp-3 {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: #fffbeb;
}

::-webkit-scrollbar-thumb {
    background: linear-gradient(to bottom, #92400e, #78350f);
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(to bottom, #78350f, #451a03);
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes pulse-glow {
    0%, 100% {
        box-shadow: 0 0 20px rgba(146, 64, 14, 0.3);
    }
    50% {
        box-shadow: 0 0 40px rgba(245, 158, 11, 0.5);
    }
}

@keyframes shine {
    0% {
        left: -100%;
    }
    100% {
        left: 100%;
    }
}

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

.animate-fade-in-up {
    animation: fadeInUp 0.8s ease-out forwards;
}

.animate-pulse-glow {
    animation: pulse-glow 2s ease-in-out infinite;
}

.animate-slide-down {
    animation: slideDown 0.4s ease-out forwards;
}

.nav-link {
    position: relative;
}

.nav-link::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 0;
    width: 0;
    height: 2px;
    background: linear-gradient(to right, #92400e, #f59e0b);
    transition: width 0.3s ease;
}

.nav-link:hover::after {
    width: 100%;
}

.service-card {
    position: relative;
    overflow: hidden;
}

.service-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(146, 64, 14, 0.08), transparent);
    transition: left 0.6s ease;
}

.service-card:hover::before {
    left: 100%;
}

.song-card {
    position: relative;
    overflow: hidden;
}

.song-card::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(245, 158, 11, 0.15) 0%, transparent 70%);
    transition: all 0.5s ease;
}

.song-card:hover::before {
    width: 200%;
    height: 200%;
}

.product-card {
    position: relative;
    overflow: hidden;
}

.product-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    z-index: 5;
    pointer-events: none;
}

.product-card:hover::before {
    animation: shine 1.2s ease;
}

.social-card {
    position: relative;
    overflow: hidden;
}

.social-card::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(to right, #fbbf24, #f59e0b);
    transform: scaleX(0);
    transform-origin: center;
    transition: transform 0.4s ease;
}

.social-card:hover::after {
    transform: scaleX(1);
}

.news-card {
    position: relative;
    overflow: hidden;
}

.news-card::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(to right, #92400e, #f59e0b, #92400e);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.4s ease;
}

.news-card:hover::after {
    transform: scaleX(1);
}

.gallery-item {
    position: relative;
    overflow: hidden;
}

.gallery-item::before {
    content: '';
    position: absolute;
    inset: 0;
    border: 0px solid rgba(245, 158, 11, 0.7);
    transition: all 0.3s ease;
    z-index: 1;
    pointer-events: none;
}

.gallery-item:hover::before {
    border-width: 4px;
}

/* Admin Panel Styles */
.admin-input,
.admin-select,
.admin-textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid #fed7aa;
    border-radius: 0.75rem;
    background-color: white;
    transition: all 0.3s ease;
    font-family: 'Sarabun', sans-serif;
    font-size: 1rem;
    color: #451a03;
}

.admin-input:focus,
.admin-select:focus,
.admin-textarea:focus {
    outline: none;
    border-color: #92400e;
    box-shadow: 0 0 0 4px rgba(245, 158, 11, 0.15);
}

.admin-label {
    display: block;
    font-weight: 600;
    color: #78350f;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

.admin-btn {
    padding: 0.75rem 1.5rem;
    border-radius: 0.75rem;
    font-weight: 700;
    transition: all 0.3s ease;
    cursor: pointer;
    border: 2px solid transparent;
    font-family: 'Sarabun', sans-serif;
}

.admin-btn-primary {
    background: linear-gradient(to right, #92400e, #78350f);
    color: white;
    border-color: #f59e0b;
}

.admin-btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px -5px rgba(146, 64, 14, 0.4);
}

.admin-btn-secondary {
    background-color: white;
    color: #92400e;
    border-color: #92400e;
}

.admin-btn-secondary:hover {
    background-color: #fffbeb;
    transform: translateY(-2px);
}

.admin-btn-danger {
    background: linear-gradient(to right, #dc2626, #991b1b);
    color: white;
}

.admin-btn-danger:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px -5px rgba(220, 38, 38, 0.4);
}

.admin-card {
    background: white;
    border-radius: 1.5rem;
    padding: 1.5rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
    border: 1px solid #fed7aa;
}

.admin-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 700;
}

.admin-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    border-radius: 1rem;
    overflow: hidden;
    border: 2px solid #fed7aa;
}

.admin-table thead {
    background: linear-gradient(to right, #92400e, #78350f);
    color: white;
}

.admin-table th {
    padding: 1rem;
    text-align: left;
    font-weight: 700;
}

.admin-table td {
    padding: 1rem;
    border-top: 1px solid #fed7aa;
    background-color: white;
    color: #451a03;
}

.admin-table tbody tr:hover td {
    background-color: #fffbeb;
}

.login-bg {
    background: linear-gradient(135deg, #451a03 0%, #78350f 50%, #92400e 100%);
    position: relative;
    overflow: hidden;
}

.login-bg::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image: 
        radial-gradient(circle at 20% 30%, rgba(245, 158, 11, 0.15) 0%, transparent 40%),
        radial-gradient(circle at 80% 70%, rgba(251, 191, 36, 0.15) 0%, transparent 40%);
}

.login-bg::after {
    content: '';
    position: absolute;
    inset: 0;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='60' height='60' viewBox='0 0 60 60'><g fill='%23fff' fill-opacity='0.025'><path d='M30 0 L35 25 L60 30 L35 35 L30 60 L25 35 L0 30 L25 25 Z'/></g></svg>");
}

.tab-btn {
    padding: 0.875rem 1.5rem;
    border-radius: 1rem 1rem 0 0;
    font-weight: 700;
    color: #92400e;
    background-color: #fed7aa;
    transition: all 0.3s ease;
    cursor: pointer;
    border: none;
}

.tab-btn.active {
    background-color: white;
    color: #78350f;
    box-shadow: 0 -4px 6px -1px rgba(0, 0, 0, 0.1);
    position: relative;
}

.tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(to right, #f59e0b, #fbbf24);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: slideDown 0.3s ease-out;
}

.modal {
    position: fixed;
    inset: 0;
    background-color: rgba(69, 26, 3, 0.75);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 1rem;
}

.modal.active {
    display: flex;
    animation: fadeIn 0.3s ease-out;
}

.modal-content {
    background-color: white;
    border-radius: 1.5rem;
    padding: 2rem;
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    border: 2px solid #f59e0b;
    animation: fadeInUp 0.4s ease-out;
}

.toast {
    position: fixed;
    top: 2rem;
    right: 2rem;
    padding: 1rem 1.5rem;
    border-radius: 1rem;
    color: white;
    font-weight: 600;
    z-index: 200;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.2);
    animation: slideDown 0.4s ease-out;
}

.toast-success {
    background: linear-gradient(to right, #16a34a, #15803d);
    border-left: 4px solid #86efac;
}

.toast-error {
    background: linear-gradient(to right, #dc2626, #991b1b);
    border-left: 4px solid #fca5a5;
}

.toast-info {
    background: linear-gradient(to right, #92400e, #78350f);
    border-left: 4px solid #fcd34d;
}

@media (max-width: 480px) {
    html {
        font-size: 14px;
    }

    .gallery-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.5rem;
    }

    .gallery-grid > div:nth-child(2) {
        grid-column: span 2;
        grid-row: span 1;
    }

    .admin-table {
        font-size: 0.8rem;
    }

    .admin-table th,
    .admin-table td {
        padding: 0.6rem 0.35rem;
    }

    .modal-content {
        padding: 1rem;
        border-radius: 1rem;
        margin: 0.5rem;
        max-height: 92vh;
    }

    .toast {
        top: 0.75rem;
        right: 0.75rem;
        left: 0.75rem;
        padding: 0.875rem 1rem;
        font-size: 0.9rem;
    }

    .admin-btn {
        padding: 0.625rem 1rem;
        font-size: 0.9rem;
    }

    .admin-card {
        padding: 1rem;
        border-radius: 1rem;
    }

    .tab-btn {
        padding: 0.625rem 0.875rem;
        font-size: 0.8rem;
        border-radius: 0.75rem 0.75rem 0 0;
    }

    .tab-content {
        padding: 0;
    }
}

@media (max-width: 640px) {
    #scrollTop {
        width: 3rem;
        height: 3rem;
        bottom: 1rem;
        right: 1rem;
    }

    #scrollTop i {
        font-size: 1rem;
    }

    .admin-input,
    .admin-select,
    .admin-textarea {
        padding: 0.625rem 0.875rem;
        font-size: 0.9rem;
    }

    .admin-label {
        font-size: 0.8rem;
    }
}

@media (max-width: 768px) {
    .gallery-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .gallery-grid > div:nth-child(2) {
        grid-column: span 2;
        grid-row: span 1;
    }

    .admin-table {
        font-size: 0.85rem;
    }

    .admin-table th,
    .admin-table td {
        padding: 0.75rem 0.5rem;
    }

    .modal-content {
        padding: 1.25rem;
    }

    .hero-buttons-stack {
        flex-direction: column;
        align-items: stretch;
    }

    .hero-buttons-stack > * {
        width: 100%;
    }
}

@media (min-width: 641px) and (max-width: 1024px) {
    .gallery-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 1024px) {
    .top-bar-hide-md {
        display: none !important;
    }
}
