/* Global Styles */
:root {
    --primary-color: #4285f4;
    --secondary-color: #34a853;
    --accent-color: #ea4335;
    --dark-color: #202124;
    --light-color: #f8f9fa;
    --grey-color: #5f6368;
    --border-color: #dadce0;
    --shadow-color: rgba(0, 0, 0, 0.1);
    
    --sidebar-width: 250px;
    --sidebar-collapsed-width: 70px;
    --header-height: 60px;
    --anim-speed: 0.3s;
    
    --email-color: #4285f4;
    --quotation-color: #fbbc05;
    --drive-color: #34a853;
    --sync-color: #ea4335;
}

/* Auth Check Overlay */
.auth-check {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: white;
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
}

.auth-check-content {
    text-align: center;
}

.auth-check.hidden {
    display: none;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    background-color: #f8f9fa;
    color: #202124;
    line-height: 1.6;
    overflow-x: hidden;
}

ul {
    list-style: none;
}

a {
    text-decoration: none;
    color: inherit;
}

button {
    cursor: pointer;
    border: none;
    outline: none;
    background: none;
}

input, select {
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 8px 12px;
    font-size: 14px;
    outline: none;
}

input:focus, select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(66, 133, 244, 0.2);
}

table {
    width: 100%;
    border-collapse: collapse;
}

table th, table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

table th {
    font-weight: 600;
    color: var(--grey-color);
    font-size: 13px;
    text-transform: uppercase;
}

.btn {
    padding: 8px 16px;
    border-radius: 4px;
    font-weight: 500;
    font-size: 14px;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.primary-btn {
    background-color: var(--primary-color);
    color: white;
}

.primary-btn:hover {
    background-color: #3b78e7;
}

.secondary-btn {
    background-color: white;
    color: var(--primary-color);
    border: 1px solid var(--primary-color);
}

.secondary-btn:hover {
    background-color: rgba(66, 133, 244, 0.05);
}

.action-btn {
    background-color: var(--primary-color);
    color: white;
    padding: 8px 16px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
}

.action-btn:hover {
    background-color: #3b78e7;
}

/* Layout */
.container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background-color: white;
    box-shadow: 2px 0 5px var(--shadow-color);
    z-index: 1000;
    transition: width var(--anim-speed) ease;
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
}

.sidebar-collapsed .sidebar {
    width: var(--sidebar-collapsed-width);
}

.sidebar-header {
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-header h1 {
    font-size: 20px;
    color: var(--primary-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-toggle {
    cursor: pointer;
    color: var(--grey-color);
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.sidebar-toggle:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

.sidebar-menu {
    padding: 20px 0;
    flex: 1;
}

.sidebar-menu li {
    position: relative;
}

.sidebar-menu li a {
    padding: 12px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--grey-color);
    position: relative;
    overflow: hidden;
}

.sidebar-menu li a i {
    font-size: 18px;
    min-width: 24px;
    text-align: center;
}

.sidebar-menu li.active a {
    color: var(--primary-color);
    background-color: rgba(66, 133, 244, 0.08);
}

.sidebar-menu li:hover a {
    background-color: rgba(0, 0, 0, 0.03);
}

.sidebar-menu li.active::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background-color: var(--primary-color);
}

.sidebar-footer {
    padding: 20px;
    border-top: 1px solid var(--border-color);
}

.auth-btn, .logout-btn {
    width: 100%;
    margin-bottom: 10px;
}

.logout-btn {
    background-color: #f8f9fa;
    color: var(--accent-color);
    border: 1px solid var(--border-color);
    display: none;
}

.logout-btn:hover {
    background-color: rgba(234, 67, 53, 0.05);
}

/* Main Content */
.content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 20px;
    transition: margin-left var(--anim-speed) ease;
}

.sidebar-collapsed .content {
    margin-left: var(--sidebar-collapsed-width);
}

/* Top Header */
.top-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
}

.search-bar {
    position: relative;
    width: 300px;
}

.search-bar input {
    width: 100%;
    padding-right: 40px;
}

.search-bar i {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--grey-color);
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 20px;
}

.profile-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.profile-info span {
    font-weight: 500;
}

.profile-info img {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
}

.sync-btn {
    background-color: var(--light-color);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 8px 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--grey-color);
    transition: all 0.2s ease;
}

.sync-btn:hover {
    background-color: rgba(0, 0, 0, 0.03);
}

.sync-btn i {
    font-size: 16px;
}

/* Section Styles */
section {
    display: none;
    animation: fadeIn 0.3s ease;
}

section.active-section {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

section h2 {
    margin-bottom: 24px;
    font-weight: 500;
    color: var(--dark-color);
}

.section-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.filter-controls {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Dashboard Stats */
.stats-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background-color: white;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 5px var(--shadow-color);
    display: flex;
    gap: 16px;
}

.stat-icon {
    width: 50px;
    height: 50px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: white;
    flex-shrink: 0;
}

.email-icon {
    background-color: var(--email-color);
}

.quotation-icon {
    background-color: var(--quotation-color);
}

.drive-icon {
    background-color: var(--drive-color);
}

.sync-icon {
    background-color: var(--sync-color);
}

.stat-details h3 {
    font-size: 16px;
    font-weight: 500;
    color: var(--grey-color);
    margin-bottom: 5px;
}

.stat-number, .stat-time {
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 5px;
}

.stat-desc {
    font-size: 13px;
    color: var(--grey-color);
}

/* Dashboard Widgets */
.dashboard-widgets {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.widget {
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 2px 5px var(--shadow-color);
}

.widget-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.widget-header h3 {
    font-size: 16px;
    font-weight: 500;
}

.view-all {
    font-size: 14px;
    color: var(--primary-color);
}

.widget-content {
    padding: 20px;
}

.widget-content ul {
    max-height: 300px;
    overflow-y: auto;
}

.widget-content li {
    padding: 12px 0;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.widget-content li:last-child {
    border-bottom: none;
}

.empty-list, .empty-table, .empty-state {
    color: var(--grey-color);
    text-align: center;
    padding: 30px;
    font-size: 14px;
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.empty-state i {
    font-size: 48px;
    color: var(--border-color);
}

/* File Container */
.drive-navigation {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.breadcrumb {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px;
}

.breadcrumb-item {
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    color: var(--primary-color);
}

.breadcrumb-item:hover {
    background-color: rgba(66, 133, 244, 0.08);
}

.breadcrumb-item:not(:last-child)::after {
    content: "/";
    margin-left: 8px;
    color: var(--grey-color);
}

.breadcrumb-item:last-child {
    color: var(--grey-color);
    font-weight: 500;
}

.view-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
}

.view-toggle button {
    width: 32px;
    height: 32px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--grey-color);
}

.view-toggle button:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

.view-toggle button.active {
    color: var(--primary-color);
    background-color: rgba(66, 133, 244, 0.08);
}

.files-container {
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 2px 5px var(--shadow-color);
    padding: 16px;
    min-height: 400px;
}

.files-container.grid-view {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 16px;
}

.files-container.list-view {
    display: block;
}

.file-item {
    text-align: center;
    padding: 16px;
    border-radius: 8px;
    cursor: pointer;
}

.file-item:hover {
    background-color: rgba(0, 0, 0, 0.02);
}

.file-icon {
    font-size: 40px;
    margin-bottom: 12px;
}

.folder-icon {
    color: var(--quotation-color);
}

.doc-icon {
    color: var(--primary-color);
}

.file-name {
    font-size: 14px;
    word-break: break-word;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.file-item.list-item {
    display: flex;
    align-items: center;
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.file-item.list-item .file-icon {
    margin-right: 16px;
    margin-bottom: 0;
    font-size: 24px;
}

.file-item.list-item .file-name {
    flex: 1;
}

.file-item.list-item .file-date {
    margin-left: 16px;
    color: var(--grey-color);
    font-size: 13px;
}

/* Settings Page */
.settings-container {
    max-width: 1000px;
}

.settings-group {
    margin-bottom: 30px;
}

.settings-group h3 {
    margin-bottom: 16px;
    font-weight: 500;
}

.settings-card {
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 2px 5px var(--shadow-color);
    margin-bottom: 20px;
    overflow: hidden;
}

.settings-header {
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
}

.settings-header h4 {
    font-size: 16px;
    font-weight: 500;
}

.settings-form {
    padding: 20px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--grey-color);
}

.form-group input, .form-group select {
    width: 100%;
}

.form-group small {
    display: block;
    margin-top: 4px;
    font-size: 12px;
    color: var(--grey-color);
}

.checkbox-group {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.checkbox-group input[type="checkbox"] {
    width: 18px;
    height: 18px;
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 24px;
}

.toggle-input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-label {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
    border-radius: 24px;
}

.toggle-label:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

.toggle-input:checked + .toggle-label {
    background-color: var(--primary-color);
}

.toggle-input:checked + .toggle-label:before {
    transform: translateX(26px);
}

.settings-actions {
    display: flex;
    gap: 16px;
    justify-content: flex-end;
    margin-top: 20px;
}

/* Modals */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease;
}

.modal.active {
    display: flex;
}

.modal-content {
    background-color: white;
    border-radius: 8px;
    max-width: 90%;
    width: 600px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.2);
}

.modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-size: 18px;
    font-weight: 500;
}

.close-modal {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--grey-color);
}

.close-modal:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* Email Details */
.email-details, .quotation-details {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.email-info, .quotation-info {
    padding: 16px;
    background-color: var(--light-color);
    border-radius: 8px;
}

.email-body {
    padding: 16px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    min-height: 200px;
    max-height: 400px;
    overflow-y: auto;
}

.quotation-items {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
}

.text-right {
    text-align: right;
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 2100;
    max-width: 350px;
}

.toast {
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2);
    margin-top: 12px;
    display: flex;
    align-items: center;
    padding: 16px;
    animation: slideIn 0.3s ease, fadeOut 0.3s ease forwards 2.7s;
}

.toast-icon {
    margin-right: 12px;
    font-size: 20px;
}

.toast-success {
    border-left: 4px solid var(--secondary-color);
}

.toast-success .toast-icon {
    color: var(--secondary-color);
}

.toast-error {
    border-left: 4px solid var(--accent-color);
}

.toast-error .toast-icon {
    color: var(--accent-color);
}

.toast-info {
    border-left: 4px solid var(--primary-color);
}

.toast-info .toast-icon {
    color: var(--primary-color);
}

.toast-message {
    flex: 1;
}

@keyframes slideIn {
    from { transform: translateX(100%); }
    to { transform: translateX(0); }
}

@keyframes fadeOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.8);
    z-index: 9999;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.loading-overlay.active {
    display: flex;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(66, 133, 244, 0.2);
    border-radius: 50%;
    border-top-color: var(--primary-color);
    animation: spin 1s linear infinite;
    margin-bottom: 16px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Responsive Styles */
@media (max-width: 992px) {
    .sidebar {
        width: var(--sidebar-collapsed-width);
    }
    
    .content {
        margin-left: var(--sidebar-collapsed-width);
    }
    
    .sidebar-menu li a span, 
    .sidebar-header h1, 
    .sidebar-footer span {
        display: none;
    }
    
    .stats-container {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .dashboard-widgets {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .content {
        margin-left: 0;
        padding: 10px;
    }
    
    .sidebar {
        transform: translateX(-100%);
        z-index: 1100;
    }
    
    .sidebar.mobile-active {
        transform: translateX(0);
        width: var(--sidebar-width);
    }
    
    .sidebar.mobile-active .sidebar-menu li a span, 
    .sidebar.mobile-active .sidebar-header h1, 
    .sidebar.mobile-active .sidebar-footer span {
        display: inline;
    }
    
    .top-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }
    
    .search-bar {
        width: 100%;
    }
    
    .user-profile {
        width: 100%;
        justify-content: space-between;
    }
    
    .stats-container {
        grid-template-columns: 1fr;
    }
    
    .section-controls {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }
    
    .filter-controls {
        width: 100%;
        flex-wrap: wrap;
    }
    
    .settings-form {
        grid-template-columns: 1fr;
    }
}