/* UglyMalta - Main Application Styles */

/* Reset & Base */
*,
*::before,
*::after {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    color: #F0F0F5;
    background: #0B0B0F;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a {
    color: inherit;
    text-decoration: none;
}

button {
    font-family: inherit;
}

img {
    max-width: 100%;
    height: auto;
}

/* App Layout */
#app {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.app-header {
    height: 60px;
    background: rgba(255,255,255,0.04);
    border-bottom: 1px solid rgba(255,255,255,0.08);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-brand {
    display: flex;
    align-items: center;
}

.brand-link {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 20px;
    font-weight: 700;
    color: #F0F0F5;
    transition: opacity 0.2s;
}

.brand-link:hover {
    opacity: 0.8;
}

.brand-icon {
    font-size: 24px;
    color: #FF4D4D;
}

.brand-name {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header-nav {
    display: flex;
    align-items: center;
    gap: 8px;
}

.nav-link {
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    color: #8888A0;
    transition: all 0.2s;
}

.nav-link:hover {
    background: rgba(255,255,255,0.06);
    color: #F0F0F5;
}

.nav-link.active {
    background: rgba(37,99,235,0.15);
    color: #FF4D4D;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Main Content */
.app-main {
    flex: 1;
}

/* Footer */
.app-footer {
    background: rgba(255,255,255,0.04);
    border-top: 1px solid rgba(255,255,255,0.08);
    padding: 24px;
    text-align: center;
    color: #8888A0;
    font-size: 14px;
}

/* Utility Classes */
.hidden {
    display: none !important;
}

.text-center {
    text-align: center;
}

.text-muted {
    color: #8888A0;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

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

.btn-primary {
    background: #FF4D4D;
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: #cc3333;
}

.btn-secondary {
    background: rgba(255,255,255,0.06);
    color: #C0C0D0;
}

.btn-secondary:hover:not(:disabled) {
    background: rgba(255,255,255,0.1);
}

.btn-danger {
    background: #FF4D4D;
    color: white;
}

.btn-danger:hover:not(:disabled) {
    background: #cc3333;
}

/* Forms */
.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: #C0C0D0;
    margin-bottom: 6px;
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 8px;
    font-size: 14px;
    transition: all 0.2s;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: #FF4D4D;
    box-shadow: 0 0 0 3px rgba(255, 77, 77, 0.2);
}

/* Cards */
.card {
    background: rgba(255,255,255,0.04);
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
    overflow: hidden;
}

.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.card-body {
    padding: 20px;
}

.card-footer {
    padding: 16px 20px;
    border-top: 1px solid rgba(255,255,255,0.08);
    background: #0B0B0F;
}

/* Alerts */
.alert {
    padding: 14px 16px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 14px;
}

.alert-success {
    background: rgba(34,197,94,0.1);
    color: #4ade80;
    border: 1px solid rgba(34,197,94,0.2);
}

.alert-error {
    background: rgba(220,38,38,0.1);
    color: #fca5a5;
    border: 1px solid rgba(220,38,38,0.2);
}

.alert-warning {
    background: rgba(180,130,0,0.1);
    color: #fbbf24;
    border: 1px solid rgba(180,130,0,0.2);
}

.alert-info {
    background: rgba(37,99,235,0.15);
    color: #93c5fd;
    border: 1px solid rgba(37,99,235,0.2);
}

/* Breakpoint Variables */
:root {
    --breakpoint-sm: 320px;
    --breakpoint-md: 480px;
    --breakpoint-lg: 768px;
    --breakpoint-xl: 1024px;
}

/* Mobile Menu Button */
.mobile-menu-btn {
    display: none;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

.hamburger-icon {
    position: relative;
    width: 20px;
    height: 14px;
}

.hamburger-icon::before,
.hamburger-icon::after,
.hamburger-icon span {
    position: absolute;
    left: 0;
    width: 100%;
    height: 2px;
    background: #C0C0D0;
    border-radius: 1px;
    transition: all 0.3s ease;
}

.hamburger-icon::before {
    content: '';
    top: 0;
}

.hamburger-icon span {
    top: 50%;
    transform: translateY(-50%);
}

.hamburger-icon::after {
    content: '';
    bottom: 0;
}

.mobile-menu-btn.active .hamburger-icon::before {
    transform: rotate(45deg);
    top: 50%;
}

.mobile-menu-btn.active .hamburger-icon span {
    opacity: 0;
}

.mobile-menu-btn.active .hamburger-icon::after {
    transform: rotate(-45deg);
    bottom: 50%;
}

/* Mobile Navigation Drawer */
.mobile-nav-drawer {
    display: none !important;
    position: fixed;
    top: 60px;
    right: 0;
    bottom: 0;
    width: 280px;
    max-width: 80vw;
    background: rgba(255,255,255,0.04);
    box-shadow: -4px 0 20px rgba(0,0,0,0.4);
    padding: 24px;
    z-index: 1000;
    transform: translateX(100%);
    transition: transform 0.3s ease;
}

.mobile-nav-drawer.active {
    transform: translateX(0);
}

.mobile-nav-link {
    display: flex;
    align-items: center;
    padding: 14px 16px;
    margin-bottom: 8px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 500;
    color: #C0C0D0;
    transition: all 0.2s;
    min-height: 44px;
}

.mobile-nav-link:hover,
.mobile-nav-link:active {
    background: rgba(255,255,255,0.06);
}

.mobile-nav-link.active {
    background: rgba(37,99,235,0.15);
    color: #FF4D4D;
}

/* Mobile Overlay */
.mobile-overlay {
    display: none;
    position: fixed;
    top: 60px;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.mobile-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

/* Responsive - Large tablets and desktops (1024px+) */
@media (min-width: 1024px) {
    .mobile-menu-btn,
    .mobile-nav-drawer,
    .mobile-overlay {
        display: none !important;
    }
}

/* Responsive - Tablets (768px - 1023px) */
@media (max-width: 1023px) {
    .app-header {
        padding: 0 16px;
    }
}

/* Responsive - Large phones and small tablets (480px - 767px) */
@media (max-width: 767px) {
    .header-nav {
        display: none;
    }

    .mobile-menu-btn {
        display: flex;
    }

    .mobile-nav-drawer {
        display: block !important;
    }

    .mobile-overlay {
        display: block !important;
        pointer-events: none;
    }

    .brand-name {
        display: none;
    }

    /* Larger touch targets */
    .vote-btn {
        min-height: 48px;
        font-size: 15px;
    }

    .btn {
        min-height: 44px;
    }
}

/* Responsive - Small phones (320px - 479px) */
@media (max-width: 479px) {
    .app-header {
        padding: 0 12px;
        height: 56px;
    }

    .brand-link {
        font-size: 18px;
    }

    .brand-icon {
        font-size: 22px;
    }

    .hexagon-panel {
        max-height: 80vh;
    }

    .hexagon-stats {
        flex-wrap: wrap;
    }

    .stat-item {
        flex: 1 1 45%;
    }

    .vote-buttons {
        flex-direction: column;
        gap: 8px;
    }

    .vote-btn {
        width: 100%;
    }
}

/* Responsive - Very small phones (< 320px) */
@media (max-width: 319px) {
    .app-header {
        padding: 0 8px;
    }

    .hexagon-panel-body {
        padding: 12px;
    }
}

/* Leaflet Customizations */
.leaflet-container {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.leaflet-control-zoom {
    border: none !important;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15) !important;
}

.leaflet-control-zoom a {
    border-radius: 4px !important;
    border: none !important;
}

.leaflet-control-zoom a:first-child {
    border-radius: 8px 8px 0 0 !important;
}

.leaflet-control-zoom a:last-child {
    border-radius: 0 0 8px 8px !important;
}

.leaflet-popup-content-wrapper {
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.leaflet-popup-tip {
    box-shadow: none;
}

/* Hexagon Polygon Styles */
.hexagon-polygon {
    cursor: pointer;
    transition: fill-opacity 0.2s;
}

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

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

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

.animate-slide-in {
    animation: slideIn 0.3s ease-out;
}

/* Scrollbar Styles */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #1A1A1A;
    background: rgba(255,255,255,0.06);
}

::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.15);
    border-radius: 4px;
}

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

/* Print Styles */
@media print {
    .app-header,
    .map-controls,
    .domain-selector,
    .map-legend,
    .hexagon-panel {
        display: none !important;
    }
}

/* === MOBILE-FIRST ENHANCEMENTS === */

/* Bottom Sheet States */
.hexagon-panel[data-state='peek'] { max-height: 35vh; }
.hexagon-panel[data-state='half'] { max-height: 60vh; }
.hexagon-panel[data-state='full'] { max-height: 90vh; }

.hexagon-panel .drag-handle {
    width: 40px; height: 4px; background: rgba(255,255,255,0.15);
    border-radius: 2px; margin: 8px auto 4px;
    cursor: grab;
}

/* Hide Leaflet zoom controls on mobile (use pinch) */
@media (max-width: 767px) {
    .leaflet-control-zoom { display: none !important; }
    .map-legend { display: none !important; }

    /* Domain selector into hamburger on mobile */
    .domain-selector { display: none; }

    /* Larger vote buttons on mobile */
    .vote-buttons { gap: 8px; }
    .vote-btn { min-height: 48px; font-size: 16px; }

    /* Full-width share buttons */
    .share-buttons { flex-direction: column; }
}

/* === CLUSTER MOSAIC STYLES === */
.cluster-div-icon { background: none !important; border: none !important; }
.cluster-marker {
    background: rgba(255,255,255,0.04);
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.2);
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.2s;
}
.cluster-marker:hover { transform: scale(1.05); }

.cluster-mosaic {
    display: grid;
    gap: 1px;
    background: rgba(255,255,255,0.1);
}
.cluster-mosaic.grid-6 { grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(2, 1fr); width: 90px; height: 60px; }
.cluster-mosaic.grid-4 { grid-template-columns: repeat(2, 1fr); grid-template-rows: repeat(2, 1fr); width: 64px; height: 64px; }

.cluster-mosaic img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.cluster-mosaic .placeholder {
    background: rgba(255,255,255,0.06);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #6E6E82;
    font-size: 10px;
}

.cluster-info {
    padding: 4px 8px;
    text-align: center;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
}

.cluster-info .score { font-weight: 700; }
.cluster-info .count { color: #8888A0; font-weight: 400; }


/* Lazy load fade-in */
img[loading=lazy] {
    opacity: 0;
    transition: opacity 0.3s ease;
}
img[loading=lazy].loaded,
img[loading=lazy][complete] {
    opacity: 1;
}
