/* =========================================================
   PHONE DIRECTORY — MAIN STYLESHEET
   ========================================================= */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #3498db;
    --primary-dark: #2980b9;
    --secondary: #2c3e50;
    --bg: #f0f2f5;
    --card-bg: #ffffff;
    --text: #2c3e50;
    --text-light: #7f8c8d;
    --border: #e1e4e8;
    --shadow: 0 2px 8px rgba(0,0,0,0.08);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
    --radius: 12px;
    --danger: #e74c3c;
    --success: #27ae60;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
                 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    line-height: 1.6;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    width: 100%;
}

main.container { flex: 1; }

/* =========================================================
   HEADER
   ========================================================= */
.main-header {
    background: #45aeff; /* or use your own hex code like #e2e8f0 */
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}

/* Optional: Add this if you changed the header to a dark color */
/*
.main-header {
    background: var(--secondary);
}
.main-header .user-badge { color: #e8edf2; }
.main-header .btn-outline { color: #fff; border-color: rgba(255,255,255,0.4); }
.main-header .btn-outline:hover { background: rgba(255,255,255,0.1); border-color: #fff; color: #fff; }
.main-header .logo { background: #fff; padding: 4px 8px; border-radius: 6px; }
*/

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 16px;
    padding-bottom: 16px;
    flex-wrap: wrap;
    gap: 12px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
}

.brand-link {
    display: flex;
    align-items: center;
    text-decoration: none;
}

.brand-icon { font-size: 28px; }

.brand h1 {
    font-size: 22px;
    font-weight: 700;
    color: var(--secondary);
}

/* Logo - Increased Size */
.logo {
    height: 60px;
    width: auto;
    max-width: 280px;
    display: block;
    object-fit: contain;
}

.header-nav {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.user-badge {
    font-size: 14px;
    color: var(--text-light);
    font-weight: 500;
}

/* =========================================================
   BUTTONS
   ========================================================= */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    border: 2px solid transparent;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
    white-space: nowrap;
}

.btn-primary {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}
.btn-primary:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--secondary);
    color: white;
    border-color: var(--secondary);
}
.btn-secondary:hover {
    background: #1a252f;
    transform: translateY(-1px);
}

.btn-outline {
    background: transparent;
    color: var(--text);
    border-color: var(--border);
}
.btn-outline:hover {
    background: var(--bg);
    border-color: var(--primary);
    color: var(--primary);
}

.btn-danger {
    background: var(--danger);
    color: #fff;
    border-color: var(--danger);
}
.btn-danger:hover {
    background: #c0392b;
    border-color: #c0392b;
    transform: translateY(-1px);
}

.btn-sm   { padding: 7px 14px; font-size: 13px; }
.btn-block { width: 100%; }

.inline-form { display: inline; margin: 0; }

/* =========================================================
   LOGIN
   ========================================================= */
.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 20px;
}

.login-container { width: 100%; max-width: 420px; }

.login-card {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 40px 32px;
    box-shadow: var(--shadow-lg);
    text-align: center;
}

.login-icon {
    font-size: 48px;
    margin-bottom: 12px;
}

.login-logo {
    height: 64px;
    width: auto;
    max-width: 240px;
    display: block;
    margin: 0 auto 20px;
    object-fit: contain;
}

.login-card h1 {
    font-size: 26px;
    color: var(--secondary);
    margin-bottom: 6px;
}

.login-subtitle {
    color: var(--text-light);
    font-size: 14px;
    margin-bottom: 28px;
}

.login-form { text-align: left; }

.form-group { margin-bottom: 18px; }

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text);
}

.form-group input {
    width: 100%;
    padding: 12px 14px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.2s;
}
.form-group input:focus {
    outline: none;
    border-color: var(--primary);
}

.login-hint {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
    color: var(--text-light);
}

/* =========================================================
   ALERTS
   ========================================================= */
.alert {
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 14px;
    margin-bottom: 20px;
    text-align: left;
}

.alert-error {
    background: #fdecea;
    color: var(--danger);
    border: 1px solid #f5c6c2;
}

.alert-success {
    background: #e8f8f0;
    color: var(--success);
    border: 1px solid #b7e4cc;
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 14px;
    margin: 16px 0;
}

/* =========================================================
   PAGE ACTIONS & SEARCH
   ========================================================= */
.page-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin: 20px 0 4px;
    flex-wrap: wrap;
}

.search-bar { margin: 24px 0 16px; }

.search-form {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.search-form input,
.search-form select {
    padding: 12px 16px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    background: var(--card-bg);
    transition: border-color 0.2s;
}

.search-form input {
    flex: 1;
    min-width: 220px;
}

.search-form select {
    min-width: 160px;
    cursor: pointer;
}

.search-form input:focus,
.search-form select:focus {
    outline: none;
    border-color: var(--primary);
}

.results-info {
    color: var(--text-light);
    font-size: 14px;
    margin-bottom: 16px;
}

/* =========================================================
   PUBLIC HERO
   ========================================================= */
.public-hero {
    text-align: center;
    padding: 40px 20px 10px;
}

.public-hero h2 {
    font-size: 30px;
    color: var(--secondary);
    margin-bottom: 8px;
}

.public-hero p {
    color: var(--text-light);
    font-size: 15px;
    max-width: 600px;
    margin: 0 auto;
}

/* =========================================================
   CONTACT GRID + CARDS (FIXED OVERLAP)
   ========================================================= */
.contact-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
    margin-bottom: 40px;
}

.contact-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: flex-start;
    gap: 14px;
    text-decoration: none;
    color: inherit;
    transition: all 0.2s ease;
    border: 2px solid transparent;
}

.contact-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary);
}

.avatar {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 18px;
    flex-shrink: 0;
}

.avatar-lg {
    width: 90px;
    height: 90px;
    font-size: 32px;
}

/* The right side of the card */
.contact-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

/* Header row inside the card (Title + Badge) */
.contact-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 4px;
    width: 100%;
}

.contact-card-header h3 {
    font-size: 16px;
    color: var(--secondary);
    margin: 0;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    min-width: 0;
}

/* The badge specifically inside the grid cards */
.contact-card .category-badge {
    position: static !important;
    display: inline-block;
    padding: 3px 8px;
    background: #eaf4fc;
    color: var(--primary);
    border-radius: 20px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    white-space: nowrap;
    flex-shrink: 0;
    margin-top: 2px;
}

.contact-title,
.contact-company {
    font-size: 13px;
    color: var(--text-light);
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.contact-phone {
    font-size: 13px;
    color: var(--primary);
    font-weight: 500;
    margin-top: 4px;
}

/* =========================================================
   EMPTY STATE
   ========================================================= */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 40px;
}

.empty-icon {
    font-size: 56px;
    margin-bottom: 16px;
}

.empty-state h3 {
    margin-bottom: 8px;
    color: var(--secondary);
}

.empty-state p { color: var(--text-light); }

/* =========================================================
   DETAILS PAGE HEADER
   ========================================================= */
.details-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    margin: 24px 0 40px;
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
}

.details-card.details-card-wide {
    max-width: 100%;
    width: 100%;
}

.details-header {
    display: flex;
    align-items: center;
    gap: 24px;
    padding: 32px;
    background: linear-gradient(135deg, #3498db 0%, #2c3e50 100%);
    color: white;
    flex-wrap: wrap;
}

.details-title {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.details-title h2 {
    font-size: 26px;
    margin-bottom: 4px;
    line-height: 1.2;
    word-break: break-word;
    width: 100%;
}

.details-title p {
    opacity: 0.9;
    font-size: 15px;
    margin-bottom: 12px;
    width: 100%;
}

/* Force the details header badge to behave properly */
.details-title .category-badge {
    position: static !important;
    display: inline-block !important;
    background: rgba(255, 255, 255, 0.2) !important;
    color: white !important;
    padding: 5px 14px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 4px;
    width: auto;
}

.details-body { padding: 32px; }

.info-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.info-row {
    display: flex;
    padding: 14px 0;
    border-bottom: 1px solid var(--border);
    gap: 20px;
}

.info-row:last-child { border-bottom: none; }

.info-label {
    width: 180px;
    flex-shrink: 0;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-light);
}

.info-value {
    flex: 1;
    font-size: 15px;
    color: var(--text);
    word-break: break-word;
}

.info-value a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
}

.info-value a:hover { text-decoration: underline; }

.details-actions {
    display: flex;
    gap: 12px;
    margin-top: 28px;
    padding-top: 24px;
    border-top: 1px solid var(--border);
    flex-wrap: wrap;
}

/* =========================================================
   DETAILS LAYOUT WITH SIDEBAR ADS
   ========================================================= */
.details-layout {
    display: grid;
    grid-template-columns: 1fr;
    gap: 24px;
    margin: 24px 0 40px;
}

@media (min-width: 992px) {
    .details-layout {
        grid-template-columns: minmax(0, 1fr) 300px;
    }
}

.details-main { min-width: 0; }

/* Sidebar Ads */
.details-sidebar {
    display: none;
}

@media (min-width: 992px) {
    .details-sidebar {
        display: flex;
        flex-direction: column;
        gap: 16px;
        position: sticky;
        top: 90px;
        align-self: start;
        margin: 5px;
    }
}

.ad-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    border: 1px solid var(--border);
    transition: transform 0.2s, box-shadow 0.2s;
    width: 100%;
    padding: 0;
}

.ad-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.sidebar-ad-link {
    display: block;
    width: 100%;
    height: 100%;
    text-decoration: none;
}

.sidebar-ad-img {
    display: block;
    width: 100%;
    height: auto;
    object-fit: cover;
}

.ad-placeholder {
    height: 200px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #f8f9fa;
    color: var(--text-light);
    border: 2px dashed #cbd5e1;
    border-radius: var(--radius);
    margin: 0;
    text-align: center;
    padding: 20px;
}

.ad-placeholder span {
    font-size: 20px;
    font-weight: 700;
    color: var(--secondary);
    margin-bottom: 6px;
}

.ad-placeholder small { font-size: 12px; }

/* =========================================================
   TOP & FOOTER BANNER ADS (FULL WIDTH)
   ========================================================= */
.banner-ad {
    position: relative;
    width: 100%;
    margin: 24px 0 16px;
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    background: var(--card-bg);
    padding: 5px;
}

.banner-ad-link {
    display: block;
    width: 100%;
    height: 100%;
    text-decoration: none;
    border-radius: calc(var(--radius) - 5px);
    overflow: hidden;
}

.banner-ad-img {
    display: block;
    width: 100%;
    height: auto;
    object-fit: cover;
    transition: opacity 0.2s;
}

.banner-ad-link:hover .banner-ad-img {
    opacity: 0.9;
}

.ad-label {
    position: absolute;
    top: 5px;
    right: 5px;
    background: rgba(0, 0, 0, 0.5);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 4px;
    text-transform: uppercase;
    pointer-events: none;
}

/* =========================================================
   STYLISH ABOUT BOX & RICH TEXT
   ========================================================= */
.notes-box {
    margin-top: 24px;
    border: 2px dashed var(--primary);
    border-radius: var(--radius);
    background: linear-gradient(135deg, #f8fbff 0%, #eaf4fc 100%);
    overflow: hidden;
}

.notes-box-header {
    background: var(--primary);
    color: #fff;
    font-weight: 700;
    font-size: 14px;
    padding: 10px 16px;
    letter-spacing: 0.3px;
}

.notes-box-body { padding: 16px; font-size: 14px; }

.notes-content { line-height: 1.7; }
.notes-content p { margin-bottom: 8px; }

.notes-content img {
    max-width: 100%;
    height: auto;
    border-radius: 6px;
    margin: 8px 0;
}

.notes-content a {
    color: var(--primary);
    text-decoration: underline;
}

.notes-content ul,
.notes-content ol {
    padding-left: 24px;
    margin: 8px 0;
}

.notes-content h1,
.notes-content h2,
.notes-content h3 {
    margin: 12px 0 6px;
    color: var(--secondary);
}

.notes-content blockquote {
    border-left: 3px solid var(--primary);
    padding-left: 12px;
    color: var(--text-light);
    margin: 8px 0;
}

/* =========================================================
   FORM CARD (ADD / EDIT)
   ========================================================= */
.form-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 28px;
    max-width: 760px;
    margin: 24px auto 40px;
}

.form-title {
    font-size: 22px;
    margin-bottom: 20px;
    color: var(--secondary);
}

.contact-form .form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.contact-form .form-group textarea {
    width: 100%;
    padding: 12px 14px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    resize: vertical;
    transition: border-color 0.2s;
}

.contact-form .form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
}

.form-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
    flex-wrap: wrap;
}

/* =========================================================
   QUILL RICH-TEXT EDITOR
   ========================================================= */
.notes-editor {
    background: #fff;
    border-radius: 8px;
    min-height: 160px;
    font-size: 14px;
}

.ql-toolbar.ql-snow {
    border: 2px solid var(--border);
    border-bottom: none;
    border-radius: 8px 8px 0 0;
    background: #f8f9fa;
}

.ql-container.ql-snow {
    border: 2px solid var(--border);
    border-radius: 0 0 8px 8px;
    font-family: inherit;
    font-size: 14px;
}

.ql-editor { min-height: 140px; }

/* =========================================================
   ADMIN ADS MANAGEMENT
   ========================================================= */
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    cursor: pointer;
    font-weight: 500;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
    cursor: pointer;
}

.ads-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.ads-list-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fafbfc;
    flex-wrap: wrap;
}

.ads-list-item.ad-inactive { opacity: 0.6; }

.ads-list-info {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    flex: 1;
    min-width: 0;
}

.ads-list-info strong {
    font-size: 14px;
    color: var(--secondary);
}

.ad-meta {
    font-size: 12px;
    color: var(--text-light);
}

.ad-status {
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
}

.status-active { background: #e8f8f0; color: var(--success); }
.status-inactive { background: #fdecea; color: var(--danger); }

.ads-list-actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* =========================================================
   FOOTER
   ========================================================= */
.main-footer {
    margin-top: auto;
    padding: 24px 0;
    text-align: center;
    color: #e8edf2;
    font-size: 13px;
    border-top: 1px solid var(--border);
    background: var(--secondary);
}

/* =========================================================
   RESPONSIVE
   ========================================================= */
@media (max-width: 768px) {
    .brand h1 { font-size: 18px; }
    
    /* Mobile Logo Size */
    .logo { 
        height: 45px; 
        max-width: 200px; 
    }
    
    .login-logo { height: 52px; max-width: 180px; }
    .user-badge { display: none; }

    .search-form { flex-direction: column; }
    .search-form input,
    .search-form select,
    .search-form .btn { width: 100%; }

    .contact-grid { grid-template-columns: 1fr; }

    .details-header {
        flex-direction: column;
        text-align: center;
        padding: 24px;
    }
    .details-title { align-items: center; }
    .details-title h2 { font-size: 22px; }
    
    .details-body { padding: 20px; }
    .info-row {
        flex-direction: column;
        gap: 4px;
        padding: 12px 0;
    }
    .info-label { width: auto; }
    
    .details-actions { flex-direction: column; }
    .details-actions .btn { width: 100%; }

    .login-card { padding: 32px 24px; }
    .public-hero { padding: 24px 16px 4px; }
    .public-hero h2 { font-size: 22px; }
}

@media (max-width: 640px) {
    .contact-form .form-row { grid-template-columns: 1fr; }
    .form-card { padding: 20px; }
    .page-actions { justify-content: stretch; }
    .page-actions .btn { flex: 1; }
    
    .details-actions { flex-direction: column; }
    .details-actions .btn,
    .details-actions .inline-form,
    .details-actions .inline-form button { width: 100%; }
    
    .ads-list-item { flex-direction: column; align-items: stretch; }
    .ads-list-actions { justify-content: flex-start; }
}

@media (max-width: 480px) {
    .container { padding: 0 14px; }
    .header-inner { padding-top: 12px; padding-bottom: 12px; }
    .brand-icon { font-size: 22px; }
    .brand h1 { font-size: 16px; }
}

/* =========================================================
   HEADER HERO (Centered text inside header)
   ========================================================= */
.header-hero {
    text-align: center;
    padding: 30px 20px;
    background: var(--bg); /* Gives it a slightly different background from the white header */
    border-radius: var(--radius);
    margin-top: 10px;
    border: 1px solid var(--border);
}

.header-hero h2 {
    font-size: 28px;
    color: var(--secondary);
    margin-bottom: 8px;
    font-weight: 700;
}

.header-hero p {
    color: var(--text-light);
    font-size: 15px;
    max-width: 600px;
    margin: 0 auto;
}

/* Mobile adjustments */
@media (max-width: 768px) {
    .header-hero {
        padding: 20px 15px;
    }
    .header-hero h2 {
        font-size: 22px;
    }
}
/* =========================================================
   HEADER HERO (Centered between logo and nav)
   ========================================================= */
.header-hero {
    flex: 1; /* Takes up all available space between logo and nav */
    text-align: center;
    padding: 0 20px;
}

.header-hero h2 {
    font-size: 24px;
    color: var(--secondary);
    margin-bottom: 2px;
    font-weight: 700;
}

.header-hero p {
    color: var(--text-light);
    font-size: 13px;
    margin: 0;
}

/* Adjustments for smaller screens */
@media (max-width: 900px) {
    .header-hero {
        display: none; /* Hides the text on tablets/mobile so the header doesn't get squished */
    }
}