/* ====================================
   Plaza Builder - Main Styles
   ==================================== */

/* ====================================
   CSS Reset & Base Styles
   ==================================== */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ====================================
   Utility Classes
   ==================================== */

.pointer-events-none {
    pointer-events: none;
}

.pointer-events-auto {
    pointer-events: auto;
}

/* Smooth Transitions */
.transition-smooth {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ====================================
   Custom Animations
   ==================================== */

/* Pulse Animation */
@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.7;
    }
}

.animate-pulse-slow {
    animation: pulse 3s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* Fade In Animation */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.fade-in {
    animation: fadeIn 0.3s ease-in-out;
}

/* Slide In Animations */
@keyframes slideInLeft {
    from {
        transform: translateX(-100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideInUp {
    from {
        transform: translateY(100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes slideInDown {
    from {
        transform: translateY(-100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.slide-in-left {
    animation: slideInLeft 0.3s ease-out;
}

.slide-in-right {
    animation: slideInRight 0.3s ease-out;
}

.slide-in-up {
    animation: slideInUp 0.3s ease-out;
}

.slide-in-down {
    animation: slideInDown 0.3s ease-out;
}

/* Bounce Animation */
@keyframes bounce {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-10px);
    }
}

.animate-bounce-slow {
    animation: bounce 2s ease-in-out infinite;
}

/* Shake Animation */
@keyframes shake {
    0%, 100% {
        transform: translateX(0);
    }
    10%, 30%, 50%, 70%, 90% {
        transform: translateX(-5px);
    }
    20%, 40%, 60%, 80% {
        transform: translateX(5px);
    }
}

.animate-shake {
    animation: shake 0.5s ease-in-out;
}

/* Glow Animation */
@keyframes glow {
    0%, 100% {
        box-shadow: 0 0 20px rgba(139, 92, 246, 0.5);
    }
    50% {
        box-shadow: 0 0 30px rgba(139, 92, 246, 0.8);
    }
}

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

/* Spin Animation */
@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

.animate-spin-slow {
    animation: spin 3s linear infinite;
}

/* ====================================
   Hover & Active Effects
   ==================================== */

/* Hover Scale Effects */
.hover-scale {
    transition: transform 0.2s ease-in-out;
}

.hover-scale:hover {
    transform: scale(1.05);
}

.hover-scale-110 {
    transition: transform 0.2s ease-in-out;
}

.hover-scale-110:hover {
    transform: scale(1.1);
}

.hover-scale-105 {
    transition: transform 0.2s ease-in-out;
}

.hover-scale-105:hover {
    transform: scale(1.05);
}

/* Active Scale Effects */
.active-scale:active {
    transform: scale(0.95);
}

/* Hover Lift Effect */
.hover-lift {
    transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
}

.hover-lift:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
}

/* Hover Glow Effect */
.hover-glow {
    transition: box-shadow 0.3s ease-in-out;
}

.hover-glow:hover {
    box-shadow: 0 0 20px rgba(139, 92, 246, 0.6);
}

/* ====================================
   Progress Bar
   ==================================== */

.progress-bar {
    transition: width 0.5s ease-out;
    position: relative;
    overflow: hidden;
}

.progress-bar::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.3),
        transparent
    );
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% {
        transform: translateX(-100%);
    }
    100% {
        transform: translateX(100%);
    }
}

/* ====================================
   Tooltips
   ==================================== */

.tooltip {
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease-in-out, visibility 0.2s ease-in-out;
    z-index: 100;
    pointer-events: none;
}

.tool-button:hover .tooltip {
    opacity: 1;
    visibility: visible;
}

/* ====================================
   Canvas Cursor Styles
   ==================================== */

#gameCanvas {
    cursor: grab;
}

#gameCanvas.grabbing {
    cursor: grabbing;
}

#gameCanvas.placing {
    cursor: crosshair;
}

#gameCanvas.pointer {
    cursor: pointer;
}

#gameCanvas.not-allowed {
    cursor: not-allowed;
}

/* ====================================
   Tool Buttons
   ==================================== */

.tool-button {
    position: relative;
    transition: all 0.2s ease-in-out;
}

.tool-button:hover {
    transform: scale(1.1);
}

.tool-button:active {
    transform: scale(0.95);
}

.tool-button.active {
    background: linear-gradient(135deg, #10b981, #059669) !important;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.3),
                0 8px 20px rgba(16, 185, 129, 0.5);
}

/* ====================================
   Loading Spinner
   ==================================== */

.loading-spinner {
    display: inline-block;
    width: 40px;
    height: 40px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s ease-in-out infinite;
}

.loading-spinner-small {
    width: 20px;
    height: 20px;
    border-width: 2px;
}

/* ====================================
   Notification Toast
   ==================================== */

.notification-toast {
    position: fixed;
    top: 20px;
    right: 20px;
    min-width: 300px;
    max-width: 400px;
    padding: 16px 20px;
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    z-index: 9999;
    animation: slideInRight 0.3s ease-out;
}

.notification-toast.success {
    border-left: 4px solid #10b981;
}

.notification-toast.error {
    border-left: 4px solid #ef4444;
}

.notification-toast.warning {
    border-left: 4px solid #f59e0b;
}

.notification-toast.info {
    border-left: 4px solid #3b82f6;
}

/* ====================================
   Badge
   ==================================== */

.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 2px 8px;
    font-size: 12px;
    font-weight: 600;
    border-radius: 12px;
    background: rgba(139, 92, 246, 0.2);
    color: #a78bfa;
    border: 1px solid rgba(139, 92, 246, 0.3);
}

.badge.success {
    background: rgba(16, 185, 129, 0.2);
    color: #10b981;
    border-color: rgba(16, 185, 129, 0.3);
}

.badge.error {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
    border-color: rgba(239, 68, 68, 0.3);
}

.badge.warning {
    background: rgba(245, 158, 11, 0.2);
    color: #f59e0b;
    border-color: rgba(245, 158, 11, 0.3);
}

/* ====================================
   Scrollbar Styling
   ==================================== */

/* Custom Scrollbar for Webkit browsers */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 4px;
    transition: background 0.2s ease-in-out;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.5);
}

/* Firefox Scrollbar */
* {
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.3) rgba(0, 0, 0, 0.2);
}

/* ====================================
   Glass Morphism Effects
   ==================================== */

.glass {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.glass-dark {
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* ====================================
   Card Styles
   ==================================== */

.card {
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 20px;
    transition: all 0.3s ease-in-out;
}

.card:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
}

/* ====================================
   Button Base Styles
   ==================================== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    border: none;
    outline: none;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.btn:active {
    transform: translateY(0);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: white;
}

.btn-primary:hover {
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
}

.btn-success {
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
}

.btn-success:hover {
    background: linear-gradient(135deg, #059669, #047857);
}

.btn-danger {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: white;
}

.btn-danger:hover {
    background: linear-gradient(135deg, #dc2626, #b91c1c);
}

.btn-outline {
    background: transparent;
    border: 2px solid rgba(255, 255, 255, 0.3);
    color: white;
}

.btn-outline:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.5);
}

/* ====================================
   Divider
   ==================================== */

.divider {
    height: 1px;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.2),
        transparent
    );
    margin: 16px 0;
}

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

/* Mobile First Approach */
@media (max-width: 640px) {
    .notification-toast {
        min-width: calc(100% - 40px);
        right: 20px;
        left: 20px;
    }
}

@media (max-width: 768px) {
    .card {
        padding: 16px;
    }

    .tooltip {
        display: none !important;
    }
}

/* ====================================
   Focus States (Accessibility)
   ==================================== */

button:focus-visible,
a:focus-visible {
    outline: 2px solid #6366f1;
    outline-offset: 2px;
}

/* ====================================
   Selection Styling
   ==================================== */

::selection {
    background: rgba(99, 102, 241, 0.5);
    color: white;
}

::-moz-selection {
    background: rgba(99, 102, 241, 0.5);
    color: white;
}

/* ====================================
   No Select (for UI elements)
   ==================================== */

.no-select {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* ====================================
   Z-Index Layers
   ==================================== */

.z-base {
    z-index: 1;
}

.z-overlay {
    z-index: 40;
}

.z-panel {
    z-index: 50;
}

.z-modal {
    z-index: 100;
}

.z-tooltip {
    z-index: 200;
}

.z-notification {
    z-index: 9999;
}

/* ====================================
   Entity Tooltip Styles (Shops, Parking, Amenities, Decorations)
   ==================================== */

.entity-tooltip {
    position: fixed;
    pointer-events: none;
    z-index: 200;
    padding: 12px 14px;
    background: linear-gradient(135deg, rgba(30, 27, 75, 0.95) 0%, rgba(76, 29, 149, 0.9) 100%);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    min-width: 220px;
    max-width: 300px;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.2s ease-out, transform 0.2s ease-out;
}

.entity-tooltip.visible {
    opacity: 1;
    transform: translateY(0);
    display: block !important;
}

.entity-tooltip.hidden {
    display: none !important;
}

.entity-tooltip-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
}

.entity-tooltip-type {
    font-size: 14px;
    font-weight: 700;
    color: #ffffff;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.entity-tooltip-level {
    font-size: 11px;
    font-weight: 700;
    color: #fbbf24;
    background: rgba(251, 191, 36, 0.15);
    padding: 3px 8px;
    border-radius: 6px;
    border: 1px solid rgba(251, 191, 36, 0.3);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.entity-tooltip-subtitle {
    font-size: 12px;
    color: #fbbf24;
    margin-bottom: 8px;
    font-style: italic;
}

.entity-tooltip-stats {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.entity-tooltip-stat {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    color: rgba(255, 255, 255, 0.85);
    line-height: 1.4;
}

.entity-tooltip-stat i {
    color: #a78bfa;
    flex-shrink: 0;
}

.entity-tooltip-stat-label {
    color: rgba(255, 255, 255, 0.65);
    min-width: 65px;
}

.entity-tooltip-stat-value {
    color: #ffffff;
    font-weight: 600;
}

/* ====================================
   Top Bar V2 - Improved Design
   ==================================== */

.topbar-v2 {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

/* Level Badge Pulse Animation */
@keyframes badgePulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
}

.topbar-v2 #levelBadge {
    animation: badgePulse 2s ease-in-out infinite;
}

/* Currency Card Shine Effect */
@keyframes shine {
    0% {
        transform: translateX(-100%) rotate(45deg);
    }
    100% {
        transform: translateX(200%) rotate(45deg);
    }
}

/* Mobile Stats Bar Slide Animation */
@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.topbar-v2 #mobileStatsBar {
    animation: slideDown 0.3s ease-out;
}

/* Icon Rotation on Hover */
.topbar-v2 [data-lucide="coins"]:hover {
    animation: coinSpin 0.6s ease-in-out;
}

@keyframes coinSpin {
    0% {
        transform: rotateY(0deg);
    }
    50% {
        transform: rotateY(180deg);
    }
    100% {
        transform: rotateY(360deg);
    }
}

/* Notification Badge Bounce */
@keyframes badgeBounce {
    0%, 100% {
        transform: scale(1);
    }
    25% {
        transform: scale(1.2);
    }
    50% {
        transform: scale(0.9);
    }
    75% {
        transform: scale(1.1);
    }
}

.topbar-v2 #notificationBadge:not(.hidden) {
    animation: badgeBounce 0.5s ease-in-out;
}

/* Energy Bar Gradient Animation */
@keyframes energyFlow {
    0% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0% 50%;
    }
}

.topbar-v2 #energyBarMobile,
.topbar-v2 #energyDisplay {
    background-size: 200% 200%;
    animation: energyFlow 3s ease infinite;
}

/* XP Bar Shimmer Enhancement */
.topbar-v2 .progress-bar {
    position: relative;
    overflow: hidden;
}

/* Button Ripple Effect */
@keyframes ripple {
    0% {
        transform: scale(0);
        opacity: 1;
    }
    100% {
        transform: scale(2);
        opacity: 0;
    }
}

/* Smooth transitions for all interactive elements */
.topbar-v2 button,
.topbar-v2 [role="button"],
.topbar-v2 .cursor-pointer {
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Enhanced focus states for accessibility */
.topbar-v2 button:focus-visible,
.topbar-v2 [role="button"]:focus-visible {
    outline: 2px solid rgba(139, 92, 246, 0.6);
    outline-offset: 2px;
}

/* Mobile touch target size enhancement */
@media (max-width: 640px) {
    .topbar-v2 button,
    .topbar-v2 [role="button"] {
        min-width: 44px;
        min-height: 44px;
    }
}

/* Responsive font scaling */
@media (max-width: 640px) {
    .topbar-v2 {
        font-size: 14px;
    }

    /* Inline mobile stats - extra compact for small screens */
    .topbar-v2 #levelMobileInline,
    .topbar-v2 #energyMobileInline {
        font-size: 11px;
    }

    .topbar-v2 #currentXPMobileInline,
    .topbar-v2 #maxXPMobileInline {
        font-size: 10px;
    }
}

@media (min-width: 641px) and (max-width: 1024px) {
    .topbar-v2 {
        font-size: 15px;
    }
}

@media (min-width: 1025px) {
    .topbar-v2 {
        font-size: 16px;
    }
}

/* Glass morphism effect enhancement */
.topbar-v2 .backdrop-blur-xl {
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
}

/* Improved shadow depth */
.topbar-v2 .shadow-lg {
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.3),
                0 4px 6px -2px rgba(0, 0, 0, 0.2);
}

.topbar-v2 .shadow-xl {
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.3),
                0 10px 10px -5px rgba(0, 0, 0, 0.2);
}

/* Smooth color transitions */
.topbar-v2 .transition-colors {
    transition-property: color, background-color, border-color;
    transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
    transition-duration: 200ms;
}

/* ====================================
   Mobile Touch Targets & Safe Areas
   ==================================== */

/* Safe Area Support (iOS Notch, Android Nav Bar) */
:root {
    --safe-area-top: env(safe-area-inset-top, 0px);
    --safe-area-bottom: env(safe-area-inset-bottom, 0px);
    --safe-area-left: env(safe-area-inset-left, 0px);
    --safe-area-right: env(safe-area-inset-right, 0px);
}

/* Touch Target Minimum Sizes */
@media (max-width: 768px) {
    /* All interactive elements */
    button,
    [role="button"],
    .btn,
    .interactive {
        min-width: 44px;
        min-height: 44px;
        padding: 0.75rem;
    }

    /* Icon-only buttons */
    button:has(> i:only-child) {
        width: 48px;
        height: 48px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* Increase spacing between buttons */
    .button-group > *:not(:last-child) {
        margin-right: 0.75rem;
    }

    /* Larger tap targets for rotation controls */
    #rotateCounterClockwise,
    #rotateClockwise {
        width: 56px !important;
        height: 56px !important;
        font-size: 1.25rem;
    }
}

/* Apply safe area insets to key UI elements */
/* Safe area insets for topbar - only adds padding when env() values exist (mobile with notches) */
.topbar-v2 {
    padding-top: var(--safe-area-top);
    padding-left: var(--safe-area-left);
    padding-right: var(--safe-area-right);
}

/* Bottom controls */
#quickActionContainer {
    bottom: max(1rem, calc(1rem + var(--safe-area-bottom))) !important;
    right: max(1rem, calc(1rem + var(--safe-area-right))) !important;
}

/* Rotation controls bottom padding */
.absolute.bottom-4.left-1\/2 {
    padding-bottom: max(1rem, var(--safe-area-bottom));
}

/* Full-screen modals */
.modal-overlay {
    padding-top: var(--safe-area-top);
    padding-bottom: var(--safe-area-bottom);
    padding-left: var(--safe-area-left);
    padding-right: var(--safe-area-right);
}

/* Touch Ripple Effect */
.touch-ripple {
    position: absolute;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    pointer-events: none;
    animation: ripple-animation 0.6s ease-out;
    z-index: 1000;
}

@keyframes ripple-animation {
    from {
        transform: scale(0);
        opacity: 1;
    }
    to {
        transform: scale(2);
        opacity: 0;
    }
}

/* Enhanced placement preview for mobile */
@media (max-width: 768px) {
    .placement-preview {
        filter: drop-shadow(0 0 10px rgba(255, 255, 255, 0.5));
    }

    .placement-preview.valid {
        filter: drop-shadow(0 0 10px rgba(34, 197, 94, 0.8));
    }

    .placement-preview.invalid {
        filter: drop-shadow(0 0 10px rgba(239, 68, 68, 0.8));
    }
}

/* ====================================
   Topbar Tooltips
   ==================================== */

.tooltip {
    position: absolute;
    top: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%) translateY(-4px);
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 11px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s, transform 0.2s;
    z-index: 1000;
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.tooltip::after {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-bottom-color: rgba(0, 0, 0, 0.9);
}

.has-tooltip:hover .tooltip {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ====================================
   Sidebar Navigation Button States
   ==================================== */

.sidebar-nav-btn {
    position: relative;
}

.sidebar-nav-btn.active {
    background: rgba(139, 92, 246, 0.2);
    border: 1px solid rgba(139, 92, 246, 0.3);
}

.sidebar-nav-btn.active i {
    color: rgb(167, 139, 250) !important;
}
