@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&family=Inter:wght@400;600;700&display=swap');

:root {
    --primary: #1D6AF3; /* Smoobu Blue */
    --primary-light: #5A99F7;
    --secondary: #64748b;
    --success: #00BD9D;
    --danger: #FD5B67;
    --warning: #FFB400;
    --dark: #1e293b;
    --light: #ffffff;
    --gray: #94a3b8;
    --bg-color: #F3F6FB; /* Smoobu Light Grey-Blue */
    --shadow-premium: 0 15px 40px rgba(0,0,0,0.08);
    --shadow-hover: 0 20px 50px rgba(0,0,0,0.15);
    --radius-lg: 12px;
    --radius-md: 8px;
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --glass-bg: rgba(255, 255, 255, 0.95);
    --glass-border: #e2e8f0;
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
}

body {
    background: var(--bg-color);
    font-family: 'Inter', sans-serif;
    padding-bottom: 120px;
    color: var(--dark);
    -webkit-font-smoothing: antialiased;
}

/* ==== CLEAN SAAS CARDS ==== */
.card, .modal-content, .fc, .search-box, .earnings-card {
    background: #ffffff !important;
    border: 1px solid #e2e8f0 !important;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-premium);
    backdrop-filter: none !important;
}

/* ==== CALENDAR PREMIUM ==== */
#calendar {
    padding: 20px;
    margin: 20px auto;
    max-width: 1200px;
}
.fc-toolbar-title { font-weight: 800 !important; color: var(--primary); }
.fc-button-primary { 
    background: var(--primary) !important; 
    border: none !important; 
    border-radius: 10px !important;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.2) !important;
}
.fc-event, .fc-v-event, .fc-timegrid-event {
    border: none !important;
    border-radius: 8px !important;
    font-weight: 600;
    overflow: visible !important; /* Critical to show rotated text */
}

/* Hide native event dot to only show primary icons */
.fc-daygrid-event-dot { display: none !important; }

/* Base style for vertical events in calendar */
.fc-v-event .fc-event-main {
    display: flex !important;
    flex-direction: row !important;
    align-items: stretch !important;
    justify-content: flex-start !important;
    overflow: visible !important;
    height: 100%;
    padding: 2px !important;
}

/* Vertical REF ID wrapper - using flex items instead of absolute */
.event-title-wrapper {
    display: flex !important;
    flex-direction: column !important; /* Forces items to stack vertically */
    align-items: center !important; /* Centered in the strip */
    justify-content: flex-start !important; /* Start from top */
    font-size: 13px !important;
    font-weight: 800 !important;
    color: #ffffff !important;
    background: rgba(0, 0, 0, 0.25) !important;
    border-radius: 4px;
    padding: 6px 0 !important;
    margin-right: 4px !important;
    flex-shrink: 0 !important;
    min-width: 24px !important; /* Wide enough for 14px icons safely */
    max-width: 24px !important;
    min-height: 100% !important; /* Ensures the background takes at least full event height */
    height: max-content !important; /* Dynamically extends vertically if icons exceed height */
    gap: 4px !important; /* Space between icons and text */
    overflow: visible !important;
}

.event-title-wrapper i {
    font-size: 14px !important;
    margin: 0 !important; /* Overrides Bootstrap utility margins, completely centers the icon */
    padding: 0 !important;
}

.event-title-wrapper span {
    writing-mode: vertical-rl !important;
    text-orientation: mixed !important;
    transform: rotate(180deg) !important;
    white-space: nowrap !important;
    font-size: 13px !important;
    margin-top: 2px !important;
}

@media (max-width: 600px) {
    .event-title-wrapper {
        font-size: 10px !important;
        min-width: 20px !important; /* Keeps icons safely within bounds */
        max-width: 20px !important;
        padding: 4px 0 !important;
    }
    .event-title-wrapper i {
        font-size: 12px !important; /* Slightly smaller to fit gracefully on mobile */
    }
}

/* Smart Filter - hide non-matching tasks */
.filtered-out {
    display: none !important;
}

/* Dropdown style matching FullCalendar buttons */
.filter-select {
    border: 1px solid var(--glass-border) !important;
    border-radius: 10px !important;
    font-size: 0.85rem !important;
    font-weight: 700 !important;
    padding: 6px 12px 6px 36px !important;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 448 512'%3E%3Cpath fill='%236366f1' d='M0 96C0 78.3 14.3 64 32 64H416c17.7 0 32 14.3 32 32s-14.3 32-32 32H32C14.3 128 0 113.7 0 96zM0 256c0-17.7 14.3-32 32-32H416c17.7 0 32 14.3 32 32s-14.3 32-32 32H32c-17.7 0-32-14.3-32-32zM448 416c0 17.7-14.3 32-32 32H32c-17.7 0-32-14.3-32-32s14.3-32 32-32H416c17.7 0 32 14.3 32 32z'/%3E%3C/svg%3E") !important;
    background-size: 16px !important;
    background-position: 10px center !important;
    background-repeat: no-repeat !important;
    color: var(--primary) !important;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
}
.filter-select:focus {
    border-color: var(--primary) !important;
    box-shadow: 0 0 0 0.25rem rgba(99, 102, 241, 0.25) !important;
}

/* ==== BUTTONS ==== */
.btn {
    border-radius: 14px;
    font-weight: 700;
    padding: 14px 24px;
    transition: var(--transition);
    border: none;
}
.btn-primary { 
    background: linear-gradient(135deg, var(--primary), var(--secondary)); 
    box-shadow: 0 8px 20px -6px rgba(99, 102, 241, 0.4);
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 12px 24px -6px rgba(99, 102, 241, 0.5); }

.btn-info {
    background: linear-gradient(135deg, #0dcaf0, #0aa2c0);
    color: white !important;
    box-shadow: 0 8px 20px -6px rgba(13, 202, 240, 0.4);
}
.btn-info:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 24px -6px rgba(13, 202, 240, 0.5);
    background: linear-gradient(135deg, #31d2f2, #0dcaf0);
}

/* ==== NAVIGATION ==== */
.nav-bar-bottom {
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(20px);
    border-top: 1px solid var(--glass-border);
    height: 75px;
    display: flex;
    justify-content: space-around;
    align-items: center;
    position: fixed;
    bottom: 0;
    width: 100%;
    z-index: 9999 !important;
}
.nav-item {
    text-decoration: none;
    color: var(--gray);
    font-size: 0.7rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: var(--transition);
}
.nav-item i { font-size: 1.4rem; margin-bottom: 4px; }
.nav-item.active { color: var(--primary); transform: translateY(-5px); }
.nav-item.active i { filter: drop-shadow(0 4px 8px rgba(99, 102, 241, 0.3)); }

/* ==== FAB ==== */
.fab-btn {
    position: fixed;
    right: 25px;
    bottom: 100px;
    width: 65px;
    height: 65px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    border-radius: 50%;
    font-size: 30px;
    border: none;
    box-shadow: 0 10px 30px rgba(99, 102, 241, 0.4);
    z-index: 999;
}

/* ==== FINANCIAL CARDS ==== */
.earnings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    padding: 20px;
}
.finance-stat {
    padding: 20px;
}
.stat-value { font-size: 1.8rem; font-weight: 800; display: block; line-height: 1.2; }
.stat-label { color: var(--gray); font-weight: 700; text-transform: uppercase; font-size: 0.65rem; letter-spacing: 0.5px; }

/* Mobile refinement for stats */
@media (max-width: 400px) {
    .stat-value { font-size: 1.4rem !important; }
}

/* ==== MODALS MOBILE FIX ==== */
.modal-dialog-centered {
    display: flex;
    align-items: center;
    min-height: calc(100% - 1rem);
}
@media (max-width: 576px) {
    .modal-content {
        max-height: 90vh;
        display: flex;
        flex-direction: column;
        border-bottom-left-radius: 0 !important;
        border-bottom-right-radius: 0 !important;
    }
    #eventModal .modal-content, #taskFormModal .modal-content {
        margin-bottom: 95px !important;
        overflow-y: auto !important;
        padding-top: calc(20px + env(safe-area-inset-top)) !important;
    }
    #eventModal .btn-close, #taskFormModal .btn-close {
        position: absolute !important;
        top: 20px !important;
        right: 15px !important;
        margin: 0 !important;
        z-index: 9999 !important;
        opacity: 1 !important;
    }
    #propModal .modal-header {
        padding-top: calc(25px + env(safe-area-inset-top)) !important;
    }
    #propModal .btn-close {
        position: absolute !important;
        top: 25px !important;
        right: 15px !important;
        margin: 0 !important;
        z-index: 9999 !important;
        opacity: 1 !important;
    }
    #propModal .modal-dialog {
        margin: 0 !important;
        max-width: 100% !important;
        width: 100% !important;
        height: 100% !important;
    }
    #propModal .modal-content {
        height: 100% !important;
        border-radius: 0 !important;
    }
    #propModal .modal-footer {
        padding-bottom: 95px !important;
    }
    #propModal .modal-footer .btn, 
    #propModal .modal-footer button {
        position: static !important;
    }
    .modal-body {
        overflow-y: auto;
        flex: 1;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 40px !important;
        overscroll-behavior: contain;
    }
    .modal-footer {
        flex-shrink: 0;
        padding-bottom: 30px !important; /* Extra space for home indicator */
    }
    .modal-dialog {
        margin: 0;
        margin-top: 10vh;
        display: flex;
        align-items: flex-end;
    }
}

body.map-page {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    height: 100dvh;
    overflow: hidden !important;
    padding-bottom: 0 !important;
    background: #f1f5f9;
}

/* ==== MAP PREMIUM ==== */
.header-map {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 100px;
    background: var(--glass-bg);
    backdrop-filter: blur(15px);
    padding: 10px 15px;
    border-bottom: 1px solid var(--glass-border);
    text-align: center;
    z-index: 9990 !important;
}

#map {
    position: absolute;
    top: 100px; /* Header height */
    bottom: 70px; /* Footer height */
    left: 0;
    right: 0;
    z-index: 1;
}

.nav-btn {
    display: inline-block;
    padding: 8px 12px;
    background: var(--primary);
    color: white !important;
    text-decoration: none;
    border-radius: 10px;
    font-weight: 700;
    font-size: 0.75rem;
    margin-top: 5px;
    transition: var(--transition);
}
.nav-btn:hover { transform: scale(1.05); }

/* ==== BAZA / APARTMENTS LIST ==== */
.search-container {
    padding: 20px;
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--bg-color);
}
/* ==== PREMIUM COLOR THEMES (Vibrant Phase) ==== */
.theme-apartment { 
    --theme-primary: var(--primary); 
    --theme-grad: var(--primary);
    --theme-light: rgba(29, 106, 243, 0.05);
}
.theme-duplex { 
    --theme-primary: #7c3aed; 
    --theme-grad: #7c3aed;
    --theme-light: rgba(124, 58, 237, 0.05);
}
.theme-villa { 
    --theme-primary: #f59e0b; 
    --theme-grad: #f59e0b;
    --theme-light: rgba(245, 158, 11, 0.05);
}

.apt-card-premium {
    background: #ffffff !important;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-premium);
    transition: all 0.2s ease-in-out;
    border: 1px solid #e2e8f0 !important;
    overflow: hidden;
    height: 100%;
    display: flex;
    flex-direction: column;
    border-top: 5px solid var(--theme-primary) !important;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.apt-card-premium:hover,
.apt-card-premium:active {
    transform: translateY(-8px);
    box-shadow: var(--shadow-hover);
    border-color: var(--theme-primary) !important;
}

.apt-media-header {
    height: 120px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f8fafc;
    border-bottom: 1px solid #f1f5f9;
}

.icon-glass-wrap {
    width: 60px;
    height: 60px;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--theme-primary);
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1);
    z-index: 2;
}

.icon-glass-wrap i { font-size: 2rem !important; }

.apt-compact-info {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    flex: 1;
}

.apt-ref-title {
    font-size: 1.25rem;
    font-weight: 900;
    color: #1e293b;
    margin-bottom: 2px;
    letter-spacing: -0.5px;
}

.info-strip {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    background: #f8fafc;
    border-radius: 8px;
    font-size: 0.85rem;
    border: 1px solid #f1f5f9;
}

.info-strip i { color: var(--gray); font-size: 1rem; }
.info-strip .value { color: #1e293b; font-weight: 700; }

.notes-compact {
    padding: 12px;
    background: var(--theme-light);
    border-radius: 8px;
    font-size: 0.8rem;
    color: #475569;
    border-left: 4px solid var(--theme-primary);
    font-weight: 500;
}

.btn-premium-group {
    display: flex;
    gap: 8px;
    padding: 16px 20px 20px;
    border-top: 1px solid #f1f5f9;
}

.btn-map-premium {
    background: var(--primary) !important;
    color: white !important;
    border: none !important;
    font-weight: 700 !important;
    font-size: 0.85rem !important;
    padding: 10px !important;
}

.btn-view-premium {
    border: 1px solid #e2e8f0 !important;
    color: #475569 !important;
    background: white !important;
    font-weight: 700 !important;
    padding: 10px !important;
}

/* ==== UTILITIES ==== */
/* Action Circles (Edit/Delete) */
.btn-action-circle {
    width: 34px !important;
    height: 34px !important;
    padding: 0 !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    background: white !important;
    border: 1px solid #e2e8f0 !important;
    transition: all 0.2s ease !important;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05) !important;
}

.btn-action-circle:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.1) !important;
    border-color: var(--primary) !important;
}

.text-gradient {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.safe-bottom {
    padding-bottom: 150px !important;
}

/* ==== PWA PUSH BANNER ==== */
.push-banner {
    background: var(--dark);
    color: white;
    padding: 15px 20px;
    font-size: 0.9rem;
    position: sticky;
    top: 0;
    z-index: 2000;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    border-bottom: 2px solid var(--primary);
}
.push-banner button {
    padding: 6px 15px !important;
    font-size: 0.75rem !important;
}

/* Utils */
.cursor-pointer { cursor: pointer; }
.hover-opacity-100:hover { opacity: 1 !important; transition: var(--transition); }
