@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
    /* Green Theme based on user request */
    --primary-color: #395C46;
    --primary-hover: #5B8A6A;
    --secondary-color: #5B8A6A;
    --success-color: #10B981;
    --danger-color: #EF4444;
    --warning-color: #F59E0B;
    --info-color: #3B82F6;
    --light-bg: #F0FDF4;
    /* Very pale green tint */
    --card-bg: #FFFFFF;
    --text-main: #111827;
    --text-muted: #6B7280;
    --border-color: #E5E7EB;
    --font-family-base: 'Inter', sans-serif;
    --sidebar-bg: #2C4A36;
    /* Slightly darker than primary for contrast */
    --sidebar-width: 250px;
}

body {
    font-family: var(--font-family-base);
    background-color: var(--light-bg);
    color: var(--text-main);
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

/* Typography */
h1,
h2,
h3,
h4,
h5,
h6 {
    font-weight: 600;
    color: var(--text-main);
}

.text-muted {
    color: var(--text-muted) !important;
}

/* Sidebar Layout */
#wrapper {
    display: flex;
    width: 100%;
    align-items: stretch;
}

#sidebar {
    min-width: var(--sidebar-width);
    max-width: var(--sidebar-width);
    background: var(--sidebar-bg);
    color: #fff;
    transition: all 0.3s;
    min-height: 100vh;
}

#sidebar.active {
    margin-left: calc(var(--sidebar-width) * -1);
}

#sidebar .sidebar-header {
    padding: 20px;
    background: rgba(0, 0, 0, 0.1);
}

#sidebar .sidebar-header h3 {
    color: #fff;
    margin-bottom: 0;
}

#sidebar ul.components {
    padding: 20px 0;
}

#sidebar ul p {
    color: #fff;
    padding: 10px;
}

#sidebar ul li a {
    padding: 10px 20px;
    font-size: 1.1em;
    display: block;
    color: #E0E7FF;
    text-decoration: none;
    transition: all 0.3s;
}

#sidebar ul li a:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.1);
}

#sidebar ul li.active>a,
a[aria-expanded="true"] {
    color: #fff;
    background: var(--primary-color);
}

a[data-toggle="collapse"] {
    position: relative;
}

.dropdown-toggle::after {
    display: block;
    position: absolute;
    top: 50%;
    right: 20px;
    transform: translateY(-50%);
}

#content {
    width: 100%;
    min-height: 100vh;
    transition: all 0.3s;
    display: flex;
    flex-direction: column;
}

/* Navbar inside content (Mobile Toggle) */
.navbar-mobile {
    padding: 10px;
    background: #fff;
    border: none;
    border-radius: 0;
    margin-bottom: 2rem;
    box-shadow: 1px 1px 3px rgba(0, 0, 0, 0.1);
}

/* Cards */
.card {
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    margin-bottom: 1.5rem;
    transition: box-shadow 0.2s ease-in-out;
}

.card:hover {
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.card-header {
    background-color: transparent;
    border-bottom: 1px solid var(--border-color);
    font-weight: 600;
    padding: 1rem 1.25rem;
}

.card-body {
    padding: 1.25rem;
}

/* Buttons */
.btn {
    font-weight: 500;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    transition: all 0.2s;
}

.btn-primary {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    border-color: var(--primary-hover);
}

.btn-icon {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

/* Forms */
.form-control,
.form-select {
    border-radius: 0.5rem;
    border-color: var(--border-color);
    padding: 0.625rem 0.75rem;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

/* Tables */
.table {
    margin-bottom: 0;
    color: var(--text-main);
}

.table th {
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    background-color: #F9FAFB;
    border-bottom: 1px solid var(--border-color);
    padding: 0.75rem 1rem;
}

.table td {
    padding: 0.75rem 1rem;
    vertical-align: middle;
    border-bottom: 1px solid var(--border-color);
}

.table-hover tbody tr:hover {
    background-color: #F9FAFB;
}

/* Helper Utilities */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
    gap: 1rem;
}

.page-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-main);
    margin: 0;
}

/* Inbox Specific */
.chat-bubble {
    padding: 0.75rem 1rem;
    border-radius: 1rem;
    margin-bottom: 0.5rem;
    max-width: 80%;
    width: fit-content;
    position: relative;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    /* Subtle shadow like Whatsapp */
}

.chat-bubble.outbound {
    background-color: #DCFCE7;
    /* Green tint */
    color: var(--text-main);
    border-bottom-right-radius: 0.25rem;
    margin-left: auto;
}

.chat-bubble.inbound {
    background-color: #FFFFFF;
    border: 1px solid var(--border-color);
    border-bottom-left-radius: 0.25rem;
    margin-right: auto;
}

.chat-meta {
    font-size: 0.7rem;
    margin-top: 0.25rem;
    opacity: 0.7;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 0.25rem;
}

/* WhatsApp Preview Styles */
.whatsapp-preview-container {
    background-color: #E5DDD5;
    border-radius: 15px;
    padding: 20px;
    min-height: 500px;
    position: sticky;
    top: 20px;
    /* Adjusted for no header */
    border: 1px solid #d1d7db;
}

.whatsapp-message {
    background-color: #FFFFFF;
    border-radius: 7.5px;
    box-shadow: 0 1px 0.5px rgba(0, 0, 0, 0.13);
    padding: 7px 7px 7px 9px;
    max-width: 320px;
    position: relative;
    font-family: Helvetica, Arial, sans-serif;
    font-size: 14.2px;
    line-height: 19px;
    color: #111b21;
    margin: 0 auto;
}

.whatsapp-header-media {
    width: 100%;
    border-radius: 7.5px;
    margin-bottom: 4px;
    background-color: #e9edef;
    min-height: 150px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.whatsapp-header-media img {
    width: 100%;
    height: auto;
    object-fit: cover;
    display: block;
}

.whatsapp-header-text {
    font-weight: bold;
    margin-bottom: 4px;
}

.whatsapp-body {
    white-space: pre-wrap;
    margin-bottom: 4px;
    word-wrap: break-word;
}

.whatsapp-footer {
    font-size: 11px;
    color: #8696a0;
    margin-top: 4px;
    margin-bottom: 2px;
}

.whatsapp-time {
    font-size: 11px;
    color: #8696a0;
    float: right;
    margin-top: 2px;
    margin-left: 8px;
    position: relative;
    top: 4px;
}

.preview-label {
    text-align: center;
    color: #54656f;
    margin-bottom: 15px;
    font-weight: 500;
}

/* Pagination Overrides */
.page-link {
    color: var(--primary-color);
    background-color: #fff;
    border: 1px solid var(--border-color);
}

.page-link:hover {
    color: var(--primary-hover);
    background-color: var(--light-bg);
    border-color: var(--border-color);
}

.page-item.active .page-link {
    z-index: 3;
    color: #fff;
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

.page-item.disabled .page-link {
    color: var(--text-muted);
    background-color: #fff;
    border-color: var(--border-color);
}

.page-link:focus {
    box-shadow: 0 0 0 0.25rem rgba(57, 92, 70, 0.25);
    /* Primary color with opacity */
}

/* Mobile Responsive */
@media (max-width: 768px) {
    #sidebar {
        margin-left: calc(var(--sidebar-width) * -1);
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        z-index: 999;
    }

    #sidebar.active {
        margin-left: 0;
        box-shadow: 3px 0 10px rgba(0, 0, 0, 0.2);
    }

    #sidebarCollapse span {
        display: none;
    }

    .page-header {
        flex-direction: column;
        align-items: stretch;
    }

    .d-none-mobile {
        display: none;
    }

    /* Inbox Mobile Overrides */
    .inbox-mobile-view {
        display: block !important;
        height: calc(100vh - 70px) !important;
    }

    /* Overlay for sidebar */
    #sidebar-overlay {
        display: none;
        position: fixed;
        width: 100vw;
        height: 100vh;
        background: rgba(0, 0, 0, 0.5);
        z-index: 998;
        top: 0;
        left: 0;
    }

    #sidebar-overlay.active {
        display: block;
    }
}