/* === CSS VARIABLES & RESET === */
:root {
    /* Apple Colors */
    --primary-color: #0071e3; /* Classic Apple Blue */
    --bg-color: #f5f5f7;       /* Off-white Apple bg */
    --sidebar-bg: #ffffff;
    --text-primary: #1d1d1f;
    --text-secondary: #86868b;
    --border-color: #d2d2d7;
    --glass-bg: rgba(255, 255, 255, 0.7);
    --glass-border: rgba(209, 213, 219, 0.3);
    
    /* UI Elements */
    --sidebar-width: 260px;
    --border-radius: 12px;
    --transition-speed: 0.2s;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
    overflow: hidden; /* Το dashboard έχει δικό του scroll */
}

/* === DASHBOARD LAYOUT === */
.dashboard-container {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* === SIDEBAR STYLE === */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--sidebar-bg);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 24px;
    z-index: 100;
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 20px;
    color: var(--primary-color);
    margin-bottom: 40px;
}

.logo-icon { font-size: 24px; }
.logo-text { color: var(--text-primary); font-weight: 300; }
.logo-bold { font-weight: 700; color: var(--text-primary); }

.nav-links { list-style: none; flex-grow: 1; }
.nav-links li { margin-bottom: 8px; }

.nav-links a {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: var(--text-primary);
    font-size: 15px;
    font-weight: 500;
    padding: 12px 16px;
    border-radius: 8px;
    transition: background var(--transition-speed);
}

.nav-links a i { font-size: 16px; color: var(--text-secondary); width: 20px; text-align: center;}

/* Active/Hover states */
.nav-links li.active a { background-color: rgba(0, 113, 227, 0.1); color: var(--primary-color); }
.nav-links li.active a i { color: var(--primary-color); }
.nav-links a:hover:not(.active) { background-color: #f0f0f2; }

.sidebar-footer {
    border-top: 1px solid var(--border-color);
    padding-top: 20px;
    font-size: 13px;
    color: var(--text-secondary);
}

.username { color: var(--text-primary); font-weight: 600; margin-left: 5px; }

.logout-btn {
    width: 100%;
    background: none;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 10px;
    color: #e30000;
    font-size: 14px;
    cursor: pointer;
    margin-top: 10px;
    transition: background var(--transition-speed);
}
.logout-btn:hover { background-color: #fff1f1; }

/* === MAIN CONTENT STYLE === */
.main-content {
    flex-grow: 1;
    overflow-y: auto; /* Scrollable περιοχή content */
    padding: 40px 60px;
}

.content-header { margin-bottom: 30px; }
.content-header h1 { font-size: 32px; font-weight: 700; letter-spacing: -0.5px; }
.content-header .subtitle { color: var(--text-secondary); font-size: 17px; margin-top: 5px; }

/* === THE GLASS PANEL (FORM CONTAINER) === */
.glass-panel {
    background-color: var(--glass-bg);
    backdrop-filter: blur(20px); /* Frosted Glass effect */
    -webkit-backdrop-filter: blur(20px);
    border-radius: var(--border-radius);
    border: 1px solid var(--glass-border);
    padding: 40px;
    max-width: 800px;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.03);
}

/* === FORM ELEMENTS STYLE === */
.form-section { margin-bottom: 30px; border-bottom: 1px solid var(--border-color); padding-bottom: 20px; }
.form-section:last-of-type { margin-bottom: 0; border-bottom: none; padding-bottom: 0; }

.form-section h3 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 20px;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 10px;
}
.form-section h3 i { color: var(--text-secondary); font-size: 16px; }

.form-group { margin-bottom: 15px; }
.form-row { display: flex; gap: 20px; }
.flex-1 { flex: 1; }
.flex-2 { flex: 2; }

label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
}

input, select {
    width: 100%;
    padding: 12px 16px;
    background-color: rgba(255, 255, 255, 0.8);
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 15px;
    transition: all var(--transition-speed);
}

input:focus, select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(0, 113, 227, 0.15);
}

input::placeholder { color: #b0b0b5; }

/* === APPLE STYLE SUBMIT BUTTON === */
.submit-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: auto;
    min-width: 200px;
    float: right;
    padding: 14px 24px;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 20px; /* Πιο στρογγυλεμένο κουμπί Apple */
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.3s ease;
    box-shadow: 0 2px 5px rgba(0, 113, 227, 0.2);
}

.submit-btn:hover { background-color: #0077ed; }
.submit-btn:active { transform: scale(0.98); }


/* === TABLE STYLES (Apple Design) === */
.table-panel {
    max-width: 100%; /* Ο πίνακας θέλει περισσότερο χώρο από τη φόρμα */
    padding: 0; /* Αφαιρούμε το padding για να φτάνει ο πίνακας στις άκρες */
    overflow: hidden;
}

.table-container {
    width: 100%;
    overflow-x: auto; /* Σε περίπτωση μικρής οθόνης */
}

.apple-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.apple-table th {
    background-color: rgba(245, 245, 247, 0.6);
    padding: 16px 20px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border-color);
}

.apple-table td {
    padding: 16px 20px;
    font-size: 14px;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}

/* Hover effect στις γραμμές */
.apple-table tbody tr {
    transition: background-color var(--transition-speed);
}

.apple-table tbody tr:hover {
    background-color: rgba(0, 113, 227, 0.04);
}

/* Στρογγυλεμένα badges για το "Είδος" καταστήματος */
.type-badge {
    display: inline-block;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    background-color: #e5e5ea;
    color: #1d1d1f;
}

.loading-text {
    text-align: center;
    color: var(--text-secondary);
    font-style: italic;
    padding: 30px !important;
}


/* === SEARCH BAR STYLE === */
.search-container {
    display: flex;
    align-items: center;
    background-color: rgba(255, 255, 255, 0.8);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 10px 16px;
    margin: 20px; /* Απόσταση από τις άκρες του πάνελ και τον πίνακα */
    width: 100%;
    max-width: 400px;
    transition: border-color var(--transition-speed), box-shadow var(--transition-speed);
}

.search-container:focus-within {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(0, 113, 227, 0.15);
}

.search-icon {
    color: var(--text-secondary);
    margin-right: 12px;
    font-size: 16px;
}

.search-container input {
    border: none;
    background: transparent;
    padding: 0;
    width: 100%;
    font-size: 15px;
    color: var(--text-primary);
    box-shadow: none; /* Αφαιρεί το focus effect του γενικού input css */
}

.search-container input:focus {
    box-shadow: none; /* Κρατάμε το effect μόνο στο container */
}

/* === ACTION BUTTONS (Edit/Delete) === */
.actions-cell {
    display: flex;
    gap: 8px;
}

.action-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    border-radius: 6px;
    color: var(--text-secondary);
    font-size: 15px;
    transition: all var(--transition-speed);
}

/* Hover effect για την Επεξεργασία */
.edit-btn:hover {
    color: var(--primary-color);
    background-color: rgba(0, 113, 227, 0.1);
}

/* Hover effect για τη Διαγραφή (Κόκκινο Apple) */
.delete-btn:hover {
    color: #ff3b30;
    background-color: rgba(255, 59, 48, 0.1);
}

/* === MODAL STYLES (Apple Vibe) === */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; width: 100vw; height: 100vh;
    background-color: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(6px); /* Θολώνει το background πίσω από το modal */
    -webkit-backdrop-filter: blur(6px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    
    /* Για το animation εμφάνισης */
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    width: 100%;
    max-width: 600px;
    padding: 30px;
    background-color: rgba(255, 255, 255, 0.85); /* Πιο λευκό glass effect */
    transform: translateY(20px) scale(0.95);
    transition: transform 0.3s ease;
    box-shadow: 0 20px 40px rgba(0,0,0,0.2);
}

/* Όταν το modal είναι ενεργό, κάνει zoom-in και ανεβαίνει ελαφρώς */
.modal-overlay.active .modal-content {
    transform: translateY(0) scale(1);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
}

.modal-header h2 {
    font-size: 22px;
    font-weight: 600;
    color: var(--text-primary);
}

.close-btn {
    background: none; border: none; font-size: 20px;
    color: var(--text-secondary); cursor: pointer;
    transition: color var(--transition-speed);
}

.close-btn:hover { color: #ff3b30; }

.modal-actions {
    display: flex; 
    justify-content: flex-end; 
    gap: 15px; 
    margin-top: 25px;
}

/* Minimal κουμπί ακύρωσης */
.cancel-btn {
    background-color: #e5e5ea;
    color: #1d1d1f;
    border: none;
    padding: 12px 24px;
    border-radius: 20px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.3s ease;
}

.cancel-btn:hover {
    background-color: #d1d1d6;
}


/* === LOGIN PAGE STYLES === */
.login-body {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    background-color: var(--bg-color);
}

.login-wrapper {
    width: 100%;
    max-width: 400px;
    padding: 20px;
}

.login-panel {
    padding: 40px 30px;
}

.login-header {
    text-align: center;
    margin-bottom: 30px;
}

.login-header h2 {
    font-size: 28px;
    font-weight: 300;
    margin-top: 15px;
    color: var(--text-primary);
}

.login-header p {
    color: var(--text-secondary);
    font-size: 14px;
    margin-top: 5px;
}

.login-btn {
    width: 100%;
    float: none; /* Αναιρούμε το float από το γενικό submit-btn */
    margin-top: 10px;
}

/* === DASHBOARD STATS & CHARTS === */
.stats-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stats-card {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 20px 25px;
}

.card-icon {
    font-size: 28px;
    color: var(--primary-color);
    background-color: rgba(0, 113, 227, 0.1);
    padding: 15px;
    border-radius: 50%;
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.card-info h3 {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
}

.card-info p {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
    margin-top: 5px;
}

/* Charts Layout */
.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 25px;
}

.chart-container {
    padding: 25px;
}

.chart-container h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 20px;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 10px;
}

.chart-wrapper {
    position: relative;
    width: 100%;
    height: 280px; /* Σταθερό ύψος για τα γραφήματα */
}


/* === TABLE ACTIONS BAR (Search & Export) === */
.table-actions-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 20px;
    gap: 20px;
}

/* Διορθώνουμε το υπάρχον search-container για να ευθυγραμμιστεί στο flex */
.search-container {
    margin: 0 !important; 
    flex-grow: 1;
    max-width: 400px;
}

/* Apple-style Πράσινο Κουμπί Εξαγωγής */
.export-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background-color: rgba(52, 199, 89, 0.1); /* Απαλό πράσινο Apple */
    color: #34c759;
    border: 1px solid rgba(52, 199, 89, 0.3);
    border-radius: 8px;
    padding: 10px 18px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-speed);
}

.export-btn:hover {
    background-color: #34c759; /* Γίνεται solid πράσινο στο hover */
    color: white;
    box-shadow: 0 4px 12px rgba(52, 199, 89, 0.2);
}

.export-btn i {
    font-size: 15px;
}

/* === FULLCALENDAR APPLE-STYLE OVERRIDES === */
.calendar-panel {
    padding: 30px;
    margin-bottom: 20px;
}

/* Ορισμός μεταβλητών του FullCalendar στα χρώματα της Apple */
:root {
    --fc-border-color: rgba(0, 0, 0, 0.06);
    --fc-button-bg-color: rgba(0, 113, 227, 0.08);
    --fc-button-border-color: rgba(0, 113, 227, 0.15);
    --fc-button-text-color: #0071e3;
    --fc-button-hover-bg-color: #0071e3;
    --fc-button-hover-border-color: #0071e3;
    --fc-button-active-bg-color: #0071e3;
    --fc-button-active-border-color: #0071e3;
    --fc-event-bg-color: #0071e3;
    --fc-event-border-color: #0071e3;
}

.fc {
    font-family: 'Inter', sans-serif !important;
}

.fc .fc-toolbar-title {
    font-size: 20px !important;
    font-weight: 600 !important;
    color: var(--text-primary);
}

.fc .fc-button {
    font-weight: 600 !important;
    font-size: 13px !important;
    padding: 8px 14px !important;
    border-radius: 8px !important;
    transition: all var(--transition-speed) !important;
}

.fc .fc-button-primary:not(:disabled):active, 
.fc .fc-button-primary:not(:disabled).fc-button-active {
    color: white !important;
}

.fc .fc-button:focus {
    box-shadow: none !important;
}

/* Στυλ για τα κουτάκια των Ραντεβού (Events) */
.fc-event {
    padding: 4px 8px !important;
    border-radius: 6px !important;
    font-size: 12px !important;
    font-weight: 500 !important;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0, 113, 227, 0.15);
}

.fc-daygrid-block-event .fc-event-time {
    font-weight: 700 !important;
    margin-right: 4px;
}

/* Highlight για την τρέχουσα ημέρα */
.fc .fc-day-today {
    background-color: rgba(0, 113, 227, 0.03) !important;
}

/* === CRM STATUS BADGES === */
.status-badge {
    display: inline-block;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    text-align: center;
    white-space: nowrap;
}

.status-pending {
    background-color: rgba(255, 149, 0, 0.15);
    color: #ff9500; /* Apple Orange */
}

.status-presentation {
    background-color: rgba(90, 200, 250, 0.15);
    color: #007aff; /* Apple Blue */
}

.status-success {
    background-color: rgba(52, 199, 89, 0.15);
    color: #34c759; /* Apple Green */
}

.status-rejected {
    background-color: rgba(255, 59, 48, 0.15);
    color: #ff3b30; /* Apple Red */
}

/* === PROFILE PAGE & LINK === */
.client-profile-link {
    color: var(--text-primary);
    text-decoration: none;
    transition: color 0.2s ease;
}

.client-profile-link:hover {
    color: var(--primary-color);
}

.back-btn {
    background-color: rgba(142, 142, 147, 0.1);
    color: var(--text-secondary);
    padding: 8px 14px;
    border-radius: 8px;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
}

.back-btn:hover {
    background-color: rgba(142, 142, 147, 0.2);
    color: var(--text-primary);
}

.profile-grid {
    display: grid;
    grid-template-columns: 1fr 2fr; /* Το ιστορικό πιάνει περισσότερο χώρο */
    gap: 25px;
    align-items: start;
}

.profile-details h3, .profile-history h3 {
    margin-bottom: 20px;
    font-size: 16px;
    color: var(--text-primary);
}

.details-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.details-list li {
    padding: 12px 0;
    border-bottom: 1px solid rgba(0,0,0,0.05);
    font-size: 14px;
    color: var(--text-secondary);
}

.details-list li:last-child {
    border-bottom: none;
}

.details-list li i {
    color: var(--primary-color);
    width: 20px;
    text-align: center;
    margin-right: 5px;
}

.details-list li span {
    color: var(--text-primary);
    font-weight: 500;
    float: right;
}

/* Timeline Σημειώσεων */
.note-input-area {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 25px;
}

.note-input-area textarea {
    width: 100%;
    height: 80px;
    padding: 12px;
    border: 1px solid rgba(0,0,0,0.1);
    border-radius: 8px;
    font-family: 'Inter', sans-serif;
    resize: vertical;
}

.note-btn {
    align-self: flex-end;
    float: none;
    padding: 8px 16px;
}

.notes-timeline {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.note-item {
    background-color: rgba(0, 113, 227, 0.03);
    border-left: 3px solid var(--primary-color);
    padding: 15px;
    border-radius: 0 8px 8px 0;
}

.note-header {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.note-author {
    font-weight: 600;
    color: var(--primary-color);
}

.note-content {
    font-size: 14px;
    color: var(--text-primary);
    line-height: 1.5;
}

/* === MAP CONTAINER === */
.map-container {
    width: 100%;
    height: 65vh; /* Πιάνει το 65% του ύψους της οθόνης */
    border-radius: 12px;
    z-index: 1; /* Για να μην καλύπτει τα μενού αν γίνει overlap */
    border: 1px solid rgba(0, 0, 0, 0.05);
}

/* Μικροδιορθώσεις στα popups του Leaflet για να μοιάζουν Apple-style */
.leaflet-popup-content-wrapper {
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
}

.leaflet-popup-content {
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    line-height: 1.5;
}

.popup-title {
    font-weight: 600;
    color: var(--primary-color);
    font-size: 15px;
    margin-bottom: 5px;
}

/* =========================================================
   === 📱 MOBILE RESPONSIVENESS (100% Mobile Friendly) ===
   ========================================================= */

@media (max-width: 768px) {
    
    .dashboard-container {
        display: block; 
    }

    /* === 1. Ξεκλείδωμα του Sidebar === */
    /* Απελευθερώνει τα στοιχεία ώστε το μενού να μπορεί να πάει κάτω! */
    .sidebar {
        display: contents; 
    }

    /* === 2. TOP BAR (Λογότυπο) === */
    .sidebar-header {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 65px;
        background-color: rgba(255, 255, 255, 0.9);
        backdrop-filter: blur(15px);
        -webkit-backdrop-filter: blur(15px);
        border-bottom: 1px solid var(--border-color);
        display: flex;
        align-items: center;
        padding: 0 20px;
        z-index: 999;
        margin: 0;
    }

    /* === 3. ΚΟΥΜΠΙ ΑΠΟΣΥΝΔΕΣΗΣ (Πάνω δεξιά) === */
    .sidebar-footer {
        position: fixed;
        top: 13px;
        right: 20px;
        z-index: 1000;
        border: none;
        padding: 0;
        margin: 0;
    }
    
    .sidebar-footer p { display: none; } /* Κρύβουμε το "Συνδεδεμένος:..." */
    
    .logout-btn { 
        margin: 0; 
        padding: 8px 15px; 
        width: auto; 
        font-size: 13px; 
        border-radius: 20px;
        background-color: white;
        box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    }

    /* === 4. BOTTOM NAVIGATION BAR (Τώρα πάει πραγματικά κάτω!) === */
    .nav-links {
        position: fixed;
        bottom: 0;
        left: 0;
        width: 100%;
        height: calc(65px + env(safe-area-inset-bottom));
        background-color: rgba(255, 255, 255, 0.95);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        border-top: 1px solid var(--border-color);
        display: flex;
        flex-direction: row;
        justify-content: space-around;
        align-items: center;
        padding-bottom: env(safe-area-inset-bottom);
        z-index: 1000;
    }

    .nav-links li { 
        margin: 0; 
        flex: 1; 
    }
    
    .nav-links a {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 4px;
        padding: 8px 0;
        font-size: 11px;
        font-weight: 500;
        color: var(--text-secondary);
        background: transparent !important;
        border-radius: 0;
    }

    .nav-links a i { 
        font-size: 22px;
        width: auto; 
        margin: 0; 
        color: inherit;
    }
    
    .nav-links li.active a { 
        color: var(--primary-color); 
    }

    /* === 5. MAIN CONTENT (Διορθώσεις κενών) === */
    .main-content {
        padding: 85px 15px calc(85px + env(safe-area-inset-bottom)) 15px; 
        height: 100vh;
        overflow-y: auto;
    }

    .content-header h1 { font-size: 24px; }
    .content-header .subtitle { font-size: 14px; }
    .glass-panel { padding: 20px 15px; }

    /* === 6. FORMS & TABLES === */
    .form-row { flex-direction: column; gap: 0; }
    .form-group { margin-bottom: 15px; }
    .submit-btn { width: 100%; float: none; margin-top: 10px; }

    .table-actions-bar { 
        flex-direction: column; 
        align-items: stretch; 
        margin: 15px 0; 
        gap: 15px;
    }
    .search-container { max-width: 100%; margin: 0 !important; }
    .export-btn { justify-content: center; }

    .modal-content { 
        padding: 20px; 
        max-height: 85vh; 
        overflow-y: auto; 
        margin: 15px;
    }

    .profile-grid { grid-template-columns: 1fr; }
}