/* General Styling */
:root {
    --primary-color: #4a90e2;
    --secondary-color: #f5f7fa;
    --text-color: #333;
    --border-color: #dfe3e8;
    --card-shadow: 0 4px 8px rgba(0,0,0,0.1);
    --light-gray: #7f8c8d;
}

body {
    font-family: 'Kantumruy Pro', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    margin: 0;
    background-color: var(--secondary-color);
    color: var(--text-color);
}

main {
    padding: 1rem;
}

/* Header */
.main-header {
    background-color: white;
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.logo { height: 40px; margin-right: 1rem; }
.main-header h1 {
    margin: 0; font-size: 1.5rem; font-weight: 600;
    position: absolute; left: 50%; transform: translateX(-50%);
}

/* User Info and Logout */
.user-info { display: flex; align-items: center; gap: 0.75rem; }
#loggedInUsername { font-weight: 600; }
.user-avatar {
    height: 40px; width: 40px; border-radius: 50%;
    object-fit: cover; border: 2px solid var(--border-color);
}
.logout-button {
    background-color: #e74c3c; color: white; border: none; padding: 0.5rem 1rem;
    font-size: 0.9rem; font-family: 'Kantumruy Pro', sans-serif; border-radius: 4px;
    cursor: pointer; transition: background-color 0.2s;
}
.logout-button:hover { background-color: #c0392b; }

/* Navigation */
nav {
    background-color: #fff; display: flex;
    justify-content: space-around; border-bottom: 1px solid var(--border-color);
}
.nav-button {
    padding: 1rem; border: none; background: none; cursor: pointer;
    font-size: 1rem; font-family: 'Kantumruy Pro', sans-serif; font-weight: 600;
    color: #555; border-bottom: 3px solid transparent; transition: all 0.2s ease-in-out;
    flex-grow: 1; text-align: center;
}
.nav-button:hover { color: var(--primary-color); }
.nav-button.active { color: var(--primary-color); border-bottom: 3px solid var(--primary-color); }

/* Cards & Forms */
.card {
    background-color: white; padding: 1.5rem; border-radius: 8px;
    box-shadow: var(--card-shadow); margin-bottom: 1.5rem;
}
.card h2 { margin-top: 0; margin-bottom: 0; }
form { display: flex; flex-direction: column; gap: 1rem; }
input, select {
    padding: 0.75rem; font-size: 1rem; font-family: 'Kantumruy Pro', sans-serif;
    border: 1px solid var(--border-color); border-radius: 4px;
    width: 100%; box-sizing: border-box; 
}

/* Card Header for Title and Buttons */
.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

/* Toggle Button for Collapsible Form */
.toggle-button {
    background-color: #ecf0f1;
    color: var(--light-gray);
    border: 1px solid var(--border-color);
    border-radius: 50%;
    width: 28px;
    height: 28px;
    font-size: 1.5rem;
    line-height: 26px;
    text-align: center;
    cursor: pointer;
    font-weight: bold;
    padding: 0;
}
.toggle-button:hover { background-color: #dfe3e8; }

/* Styles for the Collapsible Content */
.collapsible-content {
    max-height: 1000px;
    overflow: hidden;
    transition: max-height 0.4s ease-in-out, padding 0.4s ease-in-out, margin 0.4s ease-in-out;
}
.collapsible-content.collapsed {
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
    margin-top: -1.5rem;
}
.collapsible-content form {
    margin-top: 0;
}

/* Button Styles */
.primary-button {
    background-color: var(--primary-color); color: white; border: none;
    padding: 0.8rem; font-size: 1rem; font-family: 'Kantumruy Pro', sans-serif;
    font-weight: 600; border-radius: 4px; cursor: pointer;
    transition: background-color 0.2s;
}
.primary-button:hover { background-color: #357abd; }
.primary-button:disabled { background-color: #a0a0a0; cursor: not-allowed; }

/* Secondary Button style for Export PDF */
.secondary-button {
    background-color: transparent;
    color: var(--light-gray);
    border: 1px solid var(--border-color);
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    font-family: 'Kantumruy Pro', sans-serif;
    font-weight: 600;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
}
.secondary-button:hover {
    background-color: var(--secondary-color);
    border-color: var(--light-gray);
    color: #333;
}

/* File Input Styling */
.file-label {
    background-color: #eee; padding: 0.75rem; text-align: center;
    border: 1px dashed var(--border-color); border-radius: 4px; cursor: pointer;
}
input[type="file"] { display: none; }

/* Tables */
.table-container { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; margin-top: 0; }
th, td {
    border: 1px solid var(--border-color); padding: 0.75rem;
    text-align: left; white-space: nowrap; vertical-align: middle;
}
th { background-color: #f9fafb; font-weight: 600; }

/* Style for the table footer (Grand Total) */
tfoot tr {
    background-color: #f9fafb;
    font-weight: bold;
    border-top: 2px solid #bdc3c7;
}
tfoot td {
    text-align: right;
    font-size: 1.1rem;
    color: var(--primary-color);
}

td img { max-width: 50px; height: 50px; border-radius: 5px; vertical-align: middle; object-fit: cover; }
.sales-user-avatar { width: 35px; height: 35px; border-radius: 50%; margin-right: 10px; object-fit: cover; }

/* Footer */
.main-footer {
    text-align: center; padding: 1rem; background-color: #fff;
    border-top: 1px solid var(--border-color); margin-top: 2rem;
    font-size: 0.9rem; color: #555;
}
.main-footer p { margin: 0.25rem 0; }

/* Settings Page Specific Styles */
.profile-card { text-align: center; }
.settings-avatar {
    width: 120px; height: 120px; border-radius: 50%; object-fit: cover;
    border: 4px solid var(--primary-color); margin-bottom: 1rem;
}
.profile-card h3 { font-size: 1.5rem; margin: 0 0 1.5rem 0; }
#profileImageForm { max-width: 300px; margin: auto; }

/* Mobile Responsiveness */
@media (max-width: 768px) {
    .main-header h1 { display: none; }
    .main-header { justify-content: space-between; }
    .logo { height: 30px; }
    .nav-button { padding: 0.8rem 0.5rem; font-size: 0.9rem; }
    main { padding: 0.5rem; }
    .card { padding: 1rem; }
    .card-header { margin-bottom: 1rem; }
}