/* admin/css/admin.css */
:root {
    --primary-color: #007bff;
    --secondary-color: #6c757d;
    --success-color: #28a745;
    --danger-color: #dc3545;
    --warning-color: #ffc107;
    --info-color: #17a2b8;
    --light-bg: #f8f9fa;
    --dark-bg: #343a40;
    --text-color: #212529;
    --border-color: #dee2e6;
    --sidebar-width: 215px;
    --topbar-height: 60px;
    --footer-height: 44px;
}

/* Ensure HTML and Body take full viewport height */
html, body {
    height: 100%;
    margin: 0;
    padding: 0;
}

/* Body as a flex container for overall layout */
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--light-bg);
    color: var(--text-color);
    line-height: 1.6;
    display: flex;
    flex-direction: column; /* Stacks content vertically */
    overflow: hidden; /* Prevents body scroll, allowing main-content to scroll */
}

/* Admin Wrapper for sidebar overlay functionality on smaller screens */
.admin-wrapper {
    display: flex;
    flex: 1; /* Allows admin-wrapper to grow and fill available vertical space */
    position: relative; /* Needed for the ::after overlay */
    /* No explicit height here, flex:1 makes it fill remaining space */
}

/* Sidebar Styling */
.sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(180deg, var(--dark-bg) 0%, #23272b 100%);
    color: white;
    padding: 16px;
    display: flex;
    flex-direction: column;
    box-shadow: 2px 0 5px rgba(0,0,0,0.1);
    position: fixed; /* Fixed position relative to viewport */
    height: calc(100vh - var(--footer-height)); /* Adjusted height to account for fixed footer */
    top: 0; /* Ensures it starts from the top */
    left: 0; /* Ensures it's anchored to the left */
    z-index: 1000; /* Ensure it's on top */
    transform: translateX(0); /* Default: visible on large screens */
    transition: transform 0.3s ease-in-out; /* Smooth slide transition */
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 22px;
    padding-bottom: 14px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-header h3 {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: 0.3px;
    color: var(--primary-color);
    line-height: 1.25;
}

.close-sidebar-btn {
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    display: none; /* Hidden by default, shown on mobile */
}

.sidebar-nav {
    flex-grow: 1; /* Allows navigation to take available space */
    overflow-y: auto; /* Make sidebar navigation scrollable if content exceeds height */
    padding-right: 10px; /* Add some padding for the scrollbar if present */
}

.sidebar-nav::-webkit-scrollbar {
    width: 8px;
}

.sidebar-nav::-webkit-scrollbar-track {
    background: #555;
    border-radius: 10px;
}

.sidebar-nav::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 10px;
}

.sidebar-nav::-webkit-scrollbar-thumb:hover {
    background: #0056b3;
}


.sidebar-nav ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sidebar-nav li {
    margin-bottom: 4px;
}

.sidebar-nav a {
    color: rgba(255,255,255,0.8);
    text-decoration: none;
    padding: 9px 12px;
    font-size: 0.88rem;
    display: block;
    border-radius: 5px;
    border-left: 3px solid transparent;
    transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease, padding-left 0.2s ease;
    display: flex;
    align-items: center;
}

.sidebar-nav a:hover {
    background-color: rgba(255,255,255,0.08);
    color: white;
    padding-left: 16px;
}

.sidebar-nav a.active {
    background-color: var(--primary-color);
    color: white;
    border-left-color: #fff;
}

.sidebar-nav a i {
    margin-right: 9px;
    font-size: 0.95rem;
    width: 16px; /* Fixed width for icon to align text */
    text-align: center;
    flex-shrink: 0;
}

.sidebar-footer {
    margin-top: auto; /* Pushes content to the bottom */
    padding-top: 20px;
    border-top: 1px solid rgba(255,255,255,0.1);
    text-align: center;
}

.sidebar-footer a {
    color: var(--danger-color);
    text-decoration: none;
    padding: 10px 15px;
    display: block;
    border-radius: 5px;
    transition: background-color 0.2s ease, color 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar-footer a:hover {
    background-color: rgba(220, 53, 69, 0.2);
    color: var(--danger-color);
}


/* Topbar Styling */
.admin-topbar {
    margin-left: var(--sidebar-width); /* Push topbar content away from sidebar on large screens */
    background-color: white;
    height: var(--topbar-height);
    display: flex;
    align-items: center;
    padding: 0 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    z-index: 999;
    width: calc(100% - var(--sidebar-width)); /* Take remaining width next to sidebar */
    transition: width 0.3s ease-in-out, margin-left 0.3s ease-in-out;
    position: fixed; /* Fixed position relative to viewport */
    top: 0;
    left: 0; /* Position from left edge of viewport (margin-left handles actual placement) */
}

.open-sidebar-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-color);
    display: none; /* Hidden by default, shown on mobile */
    margin-right: 15px; /* Spacing from title/logo if present */
}

.topbar-right {
    margin-left: auto;
    font-weight: bold;
    color: var(--primary-color);
    display: flex;
    align-items: center;
    gap: 10px; /* Space between elements in topbar-right */
}
.topbar-right span {
    font-weight: normal;
    color: var(--text-color);
}
.topbar-right .user-info {
    font-weight: bold;
    color: var(--primary-color);
}

/* Main Content Area Styling */
.admin-main-content {
    margin-left: var(--sidebar-width); /* On large screens, this pushes content away from sidebar */
    flex-grow: 1; /* Allows it to take remaining width in .admin-wrapper */
    background-color: var(--light-bg);
    transition: margin-left 0.3s ease-in-out;
    box-sizing: border-box; /* Include padding in element's total width/height */

    /* Calculate height to fit between topbar and footer */
    height: calc(100vh - var(--topbar-height) - var(--footer-height));
    padding: 30px; /* General padding */
    padding-left: 50px;
    padding-top: calc(var(--topbar-height) + 30px); /* Adjust top padding to clear topbar */
    overflow-y: auto; /* CRITICAL: Make content area scrollable */
    display: flex;
    flex-direction: column; /* Stack children vertically */
}

.admin-main-content::-webkit-scrollbar {
    width: 10px;
}

.admin-main-content::-webkit-scrollbar-track {
    background: var(--light-bg);
}

.admin-main-content::-webkit-scrollbar-thumb {
    background: #c1c9d0;
    border-radius: 10px;
}

.admin-main-content::-webkit-scrollbar-thumb:hover {
    background: var(--primary-color);
}

/* Overlay for mobile when sidebar is active */
.admin-wrapper::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 900; /* Below sidebar, above main content */
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease-in-out, visibility 0.3s ease-in-out;
}

.admin-wrapper.sidebar-active::after {
    opacity: 1;
    visibility: visible;
}


/* Admin Page Content Section Styles */
.admin-content-section {
    background-color: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    border: 1px solid rgba(0,0,0,0.04);
    margin-bottom: 20px;
    width: 100%;
    box-sizing: border-box;
    flex-shrink: 0;
    position: relative; /* Ensure it flows naturally */
}

.admin-page-header {
    margin-bottom: 20px;
}

.admin-page-header h2 {
    margin: 0;
    color: var(--primary-color);
}


/* Dashboard Grid Styling */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-top: 20px;
    width: 100%;
    box-sizing: border-box;
}

.dashboard-card {
    background-color: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    text-align: center;
    border-top: 3px solid var(--primary-color);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.dashboard-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(0,0,0,0.12);
}

.dashboard-card h4 {
    margin-top: 0;
    color: var(--primary-color);
    font-size: 1.2rem;
}
.dashboard-card p {
    font-size: 2rem;
    margin: 10px 0 0;
    font-weight: bold;
    color: var(--text-color);
}

/* General Table Styling */
.table-container {
    overflow-x: auto;
    margin-top: 20px;
    background-color: transparent;
    border-radius: 0;
    box-shadow: none;
    width: 100%;
    box-sizing: border-box;
}
table {
    width: 100%;
    border-collapse: collapse;
    background-color: transparent;
}

th, td {
    padding: 12px 15px;
    border-bottom: 1px solid var(--border-color);
    text-align: left;
}

th {
    background-color: var(--primary-color);
    color: white;
    font-weight: bold;
}

th:first-child { border-top-left-radius: 6px; }
th:last-child { border-top-right-radius: 6px; }

tr:nth-child(even) {
    background-color: #f2f2f2;
}

tr {
    transition: background-color 0.15s ease;
}

tr:hover {
    background-color: #e9ecef;
}

.action-buttons {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-start;
}

.action-buttons a,
.action-buttons button {
    padding: 8px 12px;
    border-radius: 5px;
    text-decoration: none;
    color: white;
    font-size: 0.9em;
    cursor: pointer;
    border: none;
    transition: background-color 0.2s ease, transform 0.15s ease, box-shadow 0.2s ease;
}

.action-buttons a:hover,
.action-buttons button:hover {
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.15);
}

.action-buttons .edit-btn {
    background-color: var(--info-color);
}
.action-buttons .edit-btn:hover {
    background-color: #117a8b;
}

.action-buttons .delete-btn {
    background-color: var(--danger-color);
}
.action-buttons .delete-btn:hover {
    background-color: #bd2130;
}

.action-buttons .view-btn {
    background-color: var(--secondary-color);
}
.action-buttons .view-btn:hover {
    background-color: #5a6268;
}

.action-buttons .approve-btn {
    background-color: var(--success-color);
}
.action-buttons .approve-btn:hover {
    background-color: #1e7e34;
}

/* General Forms */
.form-container {
    background-color: transparent;
    padding: 0;
    border-radius: 0;
    box-shadow: none;
    margin-top: 20px;
    width: 100%;
    box-sizing: border-box;
}

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: bold;
    color: #333;
}

.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="password"],
.form-group input[type="date"],
.form-group input[type="number"],
.form-group select,
.form-group textarea {
    width: calc(100% - 20px);
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 5px;
    font-size: 1rem;
    box-sizing: border-box;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-group input[type="text"]:focus,
.form-group input[type="email"]:focus,
.form-group input[type="password"]:focus,
.form-group input[type="date"]:focus,
.form-group input[type="number"]:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.15);
}

.form-group textarea {
    min-height: 100px;
    resize: vertical;
}

.form-actions {
    margin-top: 20px;
}

.form-actions button {
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1rem;
    transition: background-color 0.2s ease, transform 0.15s ease, box-shadow 0.2s ease;
}

.form-actions button:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.12);
}

.form-actions button:active {
    transform: translateY(0);
    box-shadow: none;
}

.form-actions .submit-btn {
    background-color: var(--primary-color);
    color: white;
}

.form-actions .submit-btn:hover {
    background-color: #0056b3;
}

.form-actions .cancel-btn {
    background-color: var(--secondary-color);
    color: white;
    margin-left: 10px;
}

.form-actions .cancel-btn:hover {
    background-color: #5a6268;
}

/* Messages */
.message {
    padding: 10px 20px;
    border-radius: 5px;
    margin-bottom: 20px;
    font-weight: bold;
    border-left-width: 4px;
}

.message.success {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
    border-left: 4px solid var(--success-color);
}

.message.error {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
    border-left: 4px solid var(--danger-color);
}

/* Improved Fixed Footer */
/* Slim, single-row footer: copyright/version/user on one side, socials on
   the other. The old 3-column layout (Quick Links, System Info, Connect)
   duplicated the sidebar nav and a non-live "server time" - dropped in
   favor of just the unique, useful bits. */
.admin-footer {
    height: var(--footer-height);
    background-color: var(--dark-bg);
    color: white;
    padding: 0 24px;
    font-size: 0.8rem;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
    box-shadow: 0 -2px 4px rgba(0,0,0,0.05);
}

.admin-footer-copyright {
    margin: 0;
    color: rgba(255,255,255,0.75);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.admin-footer-copyright strong {
    color: #fff;
}

.admin-footer-sep {
    margin: 0 6px;
    opacity: 0.5;
}

.admin-footer-socials {
    display: flex;
    gap: 12px;
    flex-shrink: 0;
}

.admin-footer-socials a i {
    color: rgba(255,255,255,0.75);
    font-size: 14px;
    transition: color 0.2s ease;
}

.admin-footer-socials a:hover i {
    color: var(--primary-color);
}

/* Responsive Design */
@media (max-width: 768px) {
    /* Adjust main content and topbar margins to 0 on small screens */
    .admin-main-content, .admin-topbar {
        margin-left: 0;
        width: 100%;
    }
    /* On small screens, padding on .admin-main-content should be uniform */
    .admin-main-content {
        padding: 20px; /* Smaller, uniform padding for mobile */
        padding-top: calc(var(--topbar-height) + 20px); /* Ensure top padding still clears topbar */
        height: calc(100vh - var(--topbar-height) - var(--footer-height)); /* Adjusted height for mobile */
    }

    /* Sidebar is hidden by default on small screens */
    .sidebar {
        transform: translateX(-100%);
        box-shadow: none; /* Remove shadow when hidden */
        height: 100%; /* On mobile, sidebar can take full viewport height, excluding footer if desired */
    }

    /* When sidebar is active on small screens */
    .sidebar.active {
        transform: translateX(0);
        box-shadow: 0 0 15px rgba(0,0,0,0.3); /* Stronger shadow when open */
    }

    /* Show hamburger and close buttons on small screens */
    .open-sidebar-btn,
    .close-sidebar-btn {
        display: block;
    }

    /* When sidebar is open, no need to shift main content, overlay covers it */
    .admin-wrapper.sidebar-active .admin-topbar,
    .admin-wrapper.sidebar-active .admin-main-content {
        margin-left: 0; /* Keep main content from shifting */
        width: 100%;
    }

    /* Adjust table layout for small screens */
    table, thead, tbody, th, td, tr {
        display: block;
    }

    thead tr {
        position: absolute;
        top: -9999px;
        left: -9999px;
    }

    tr {
        margin: 0 0 1rem 0;
        border: 1px solid var(--border-color);
        border-radius: 8px;
        box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    }

    td {
        border: none;
        position: relative;
        padding-left: 50%;
        text-align: right;
    }

    td:before {
        position: absolute;
        top: 12px; /* Center with padding */
        left: 15px;
        width: 45%;
        padding-right: 10px;
        white-space: nowrap;
        text-align: left;
        font-weight: bold;
    }

    /* Labeling for each cell on small screens (example) */
    .users-table td:nth-of-type(1):before { content: "User ID"; }
    .users-table td:nth-of-type(2):before { content: "Username"; }
    .users-table td:nth-of-type(3):before { content: "Email"; }
    .users-table td:nth-of-type(4):before { content: "Full Name"; }
    .users-table td:nth-of-type(5):before { content: "Role"; }
    .users-table td:nth-of-type(6):before { content: "Created At"; }
    .users-table td:nth-of-type(7):before { content: "Updated At"; }
    .users-table td:nth-of-type(8):before { content: "Actions"; }

    .contacts-table td:nth-of-type(2):before { content: "Full Name"; }
    .contacts-table td:nth-of-type(3):before { content: "Email"; }
    .contacts-table td:nth-of-type(4):before { content: "Phone"; }
    .contacts-table td:nth-of-type(6):before { content: "Submitted At"; }
    .contacts-table td:nth-of-type(7):before { content: "Status"; }
    .contacts-table td:nth-of-type(8):before { content: "Actions"; }

    .action-buttons {
        justify-content: flex-end;
    }

    .admin-footer {
        height: auto;
        padding: 10px 15px;
        flex-direction: column;
        gap: 6px;
        text-align: center;
    }
    .admin-footer-copyright {
        white-space: normal;
    }
}

/* Specific styles for contacts table rows */
.contacts-table tr.unread {
    font-weight: bold;
    background-color: #fff3cd; /* Light warning color */
}
.contacts-table tr.unread:hover {
    background-color: #ffeeba;
}






/* Add to admin/css/admin.css */

/* Style for dynamic social link inputs */
.form-group.social-link-item {
    display: flex;
    align-items: center;
    gap: 10px; /* Space between select, input, and button */
    margin-bottom: 10px;
    flex-wrap: wrap; /* Allow wrapping on smaller screens */
}

.form-group.social-link-item label {
    flex-basis: 100%; /* Label takes full width on its own line */
    margin-bottom: 5px;
}

.form-group.social-link-item select,
.form-group.social-link-item input[type="text"] {
    flex-grow: 1; /* Allow them to grow */
    /* Remove fixed widths if you added them inline in JS for better responsiveness */
    width: auto; /* Let flexbox control width */
}

/* Adjust button size for inline use */
.form-group.social-link-item .remove-social-link {
    padding: 8px 12px;
    font-size: 0.9em;
    white-space: nowrap; /* Prevent button text from wrapping */
}

/* Responsive adjustments for social links */
@media (max-width: 768px) {
    .form-group.social-link-item {
        flex-direction: column; /* Stack elements vertically */
        align-items: stretch; /* Stretch elements to full width */
    }
    .form-group.social-link-item select,
    .form-group.social-link-item input[type="text"],
    .form-group.social-link-item .remove-social-link {
        width: 100%; /* Full width on mobile */
        margin-right: 0 !important; /* Override inline styles if any */
        margin-left: 0 !important;
    }
    .form-group.social-link-item select {
        margin-bottom: 10px;
    }
    .form-group.social-link-item input[type="text"] {
        margin-bottom: 10px;
    }
}
/* Add this to your admin.css file */

.action-buttons .danger-btn,
.form-actions .danger-btn {
    background-color: var(--danger-color);
    color: white;
}
.action-buttons .danger-btn:hover,
.form-actions .danger-btn:hover {
    background-color: #bd2130; /* A darker red */
}

/* Inline status icon colors (analytics insights, cache messages, etc.) */
.icon-success { color: var(--success-color); }
.icon-danger { color: var(--danger-color); }
.icon-warning { color: var(--warning-color); }
.icon-info { color: var(--info-color); }
.icon-accent { color: #fd7e14; }

/* ====================
   AUTH PAGES (Login / Signup)
   ==================== */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #eef2f7 0%, #dfe7ef 100%);
    padding: 20px;
}

.auth-card {
    background: #ffffff;
    width: 100%;
    max-width: 420px;
    border-radius: 12px;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.12);
    padding: 40px;
    text-align: center;
    border-top: 4px solid var(--primary-color);
    animation: authCardIn 0.4s ease-out;
}

.auth-card.auth-card-wide {
    max-width: 460px;
}

@keyframes authCardIn {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

.auth-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 18px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color), #00b4d8);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 1.6rem;
    box-shadow: 0 8px 20px rgba(0, 123, 255, 0.3);
}

.auth-card h2 {
    margin-bottom: 6px;
    color: var(--text-color);
    font-size: 1.5rem;
}

.auth-subtitle {
    color: var(--secondary-color);
    font-size: 0.9rem;
    margin-bottom: 25px;
}

.auth-card .form-group {
    text-align: left;
}

.auth-card .form-actions {
    margin-top: 25px;
    flex-direction: column;
}

.auth-card .form-actions .submit-btn {
    width: 100%;
    padding: 13px;
    font-size: 1rem;
}

.auth-message {
    margin-bottom: 18px;
    padding: 12px 14px;
    border-radius: 6px;
    font-size: 0.9rem;
    text-align: left;
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

.auth-message i {
    margin-top: 2px;
}

.auth-message.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.auth-message.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.auth-message.warning {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffeeba;
}

.auth-footer {
    margin-top: 22px;
    font-size: 0.9rem;
    color: var(--secondary-color);
}

.auth-footer a {
    color: var(--primary-color);
    font-weight: 600;
    text-decoration: none;
}

.auth-footer a:hover {
    text-decoration: underline;
}

@media (max-width: 480px) {
    .auth-card {
        padding: 28px 22px;
    }
}

/* ====================
   TOPBAR PAGE TITLE (centered)
   ==================== */
.topbar-center {
    flex: 1 1 auto;
    display: flex;
    justify-content: center;
    align-items: center;
    min-width: 0;
    padding: 0 10px;
}

.admin-page-title {
    margin: 0;
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text-color);
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* On roomy screens, true-center the title against the whole topbar
   (not just the leftover flex space) so it reads as centered even
   when the left/right icon clusters are different widths. */
@media (min-width: 1200px) {
    .topbar-center {
        position: absolute;
        left: 50%;
        top: 50%;
        transform: translate(-50%, -50%);
        width: max-content;
        max-width: 55%;
    }
    .admin-page-title {
        font-size: 1.6rem;
    }
}




