/* PNBTravel Mail - Gmail-like Styles */

/* Reset & Base */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 14px;
    color: #202124;
    background: #f6f8fc;
    line-height: 1.5;
    overflow: hidden;
    height: 100vh;
}

a {
    color: #1a73e8;
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

button {
    cursor: pointer;
    border: none;
    background: none;
    font-family: inherit;
    font-size: inherit;
}

input, textarea {
    font-family: inherit;
    font-size: inherit;
}

/* App Layout */
.app-layout {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

/* Header */
.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 16px;
    background: white;
    border-bottom: 1px solid #e0e0e0;
    height: 56px;
    z-index: 100;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 200px;
}

.logo {
    font-size: 20px;
    font-weight: 700;
    color: #1a73e8;
    text-decoration: none;
}

.logo:hover {
    text-decoration: none;
}

.header-center {
    flex: 1;
    max-width: 720px;
    margin: 0 24px;
}

.search-container {
    position: relative;
    width: 100%;
}

.search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #5f6368;
}

.search-input {
    width: 100%;
    padding: 10px 16px 10px 40px;
    background: #f1f3f4;
    border: none;
    border-radius: 24px;
    font-size: 14px;
    color: #202124;
    transition: background 0.2s, box-shadow 0.2s;
}

.search-input:focus {
    outline: none;
    background: white;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.search-input::placeholder {
    color: #5f6368;
}

.search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border-radius: 0 0 8px 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    max-height: 400px;
    overflow-y: auto;
    display: none;
    z-index: 200;
}

.search-results.active {
    display: block;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    color: #5f6368;
    transition: background 0.2s;
}

.btn-icon:hover {
    background: #f1f3f4;
}

.user-menu {
    position: relative;
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #1a73e8;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
}

.user-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    min-width: 200px;
    padding: 8px 0;
    display: none;
    z-index: 200;
}

.user-dropdown.active {
    display: block;
}

.user-info {
    padding: 12px 16px;
}

.user-info strong {
    display: block;
    color: #202124;
}

.user-info small {
    color: #5f6368;
}

.user-dropdown hr {
    border: none;
    border-top: 1px solid #e0e0e0;
    margin: 4px 0;
}

.dropdown-item {
    display: block;
    padding: 8px 16px;
    color: #202124;
    transition: background 0.2s;
}

.dropdown-item:hover {
    background: #f1f3f4;
    text-decoration: none;
}

/* Main Content */
.app-content {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: 240px;
    background: white;
    border-right: 1px solid #e0e0e0;
    display: flex;
    flex-direction: column;
    padding: 12px;
    overflow-y: auto;
    transition: transform 0.3s, width 0.3s;
}

.sidebar.collapsed {
    transform: translateX(-240px);
    width: 0;
    padding: 0;
    overflow: hidden;
}

.btn-compose {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 24px;
    background: #c2e7ff;
    color: #001d35;
    border-radius: 16px;
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 16px;
    transition: box-shadow 0.2s;
}

.btn-compose:hover {
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.folder-list {
    flex: 1;
}

.folder-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    border-radius: 0 16px 16px 0;
    color: #202124;
    transition: background 0.2s;
    text-decoration: none;
    font-size: 13px;
}

.folder-item:hover {
    background: #f1f3f4;
    text-decoration: none;
}

.folder-item.active {
    background: #d3e3fd;
    color: #001d35;
    font-weight: 600;
}

.folder-icon {
    flex-shrink: 0;
    color: #5f6368;
}

.folder-item.active .folder-icon {
    color: #001d35;
}

.folder-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.badge {
    background: #1a73e8;
    color: white;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
}

.sidebar-footer {
    padding-top: 12px;
    border-top: 1px solid #e0e0e0;
    margin-top: 12px;
}

.btn-new-folder {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    color: #5f6368;
    font-size: 13px;
    border-radius: 8px;
    width: 100%;
    transition: background 0.2s;
}

.btn-new-folder:hover {
    background: #f1f3f4;
}

/* Email List */
.email-list-container {
    flex: 1;
    min-width: 320px;
    max-width: 480px;
    background: white;
    border-right: 1px solid #e0e0e0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.email-list-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid #e0e0e0;
}

.folder-title {
    font-size: 16px;
    font-weight: 600;
    color: #202124;
}

.email-list {
    flex: 1;
    overflow-y: auto;
}

.email-row {
    display: flex;
    align-items: flex-start;
    padding: 12px 16px;
    border-bottom: 1px solid #f1f3f4;
    cursor: pointer;
    transition: background 0.2s;
    gap: 12px;
}

.email-row:hover {
    background: #f6f8fc;
}

.email-row.active {
    background: #d3e3fd;
}

.email-row.unread {
    background: #ffffff;
}

.email-row.unread .email-from {
    font-weight: 700;
    color: #202124;
}

.email-row.unread .email-subject {
    font-weight: 600;
}

.email-row-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-star {
    padding: 4px;
    border-radius: 50%;
    transition: background 0.2s;
}

.btn-star:hover {
    background: #f1f3f4;
}

.email-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 12px;
    flex-shrink: 0;
}

.email-row-content {
    flex: 1;
    min-width: 0;
}

.email-row-top {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 2px;
}

.email-from {
    font-size: 13px;
    color: #5f6368;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}

.email-time {
    font-size: 11px;
    color: #5f6368;
    flex-shrink: 0;
    margin-left: 8px;
}

.email-row-subject {
    font-size: 13px;
    color: #202124;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-bottom: 2px;
}

.email-row-preview {
    font-size: 12px;
    color: #5f6368;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.email-attachment-icon {
    color: #5f6368;
    flex-shrink: 0;
    margin-top: 4px;
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 24px;
    text-align: center;
}

.empty-state p {
    color: #5f6368;
    margin: 16px 0;
}

.btn-sync {
    padding: 8px 16px;
    background: #1a73e8;
    color: white;
    border-radius: 4px;
    font-size: 13px;
}

.btn-sync:hover {
    background: #1557b0;
}

.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 12px;
    border-top: 1px solid #e0e0e0;
}

.btn-page {
    padding: 6px 12px;
    background: #1a73e8;
    color: white;
    border-radius: 4px;
    font-size: 13px;
}

.btn-page:hover {
    background: #1557b0;
    text-decoration: none;
}

.page-info {
    font-size: 13px;
    color: #5f6368;
}

/* Reading Pane */
.reading-pane {
    flex: 1;
    background: white;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.reading-pane-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #5f6368;
}

.reading-pane-empty p {
    margin-top: 16px;
    font-size: 14px;
}

.reading-pane-content {
    padding: 24px;
}

.reading-header {
    margin-bottom: 24px;
}

.reading-actions {
    display: flex;
    gap: 4px;
    margin-bottom: 16px;
}

.reading-subject {
    font-size: 22px;
    font-weight: 400;
    color: #202124;
    margin-bottom: 16px;
    line-height: 1.3;
}

.reading-meta {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.reading-from {
    display: flex;
    align-items: center;
    gap: 12px;
}

.reading-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #1a73e8;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 16px;
}

.reading-from strong {
    display: block;
    color: #202124;
    font-size: 14px;
}

.reading-from small {
    color: #5f6368;
    font-size: 12px;
}

.reading-details {
    text-align: right;
    font-size: 12px;
    color: #5f6368;
}

.reading-details span {
    display: block;
}

.reading-body {
    padding: 16px 0;
    border-top: 1px solid #e0e0e0;
    line-height: 1.6;
    font-size: 14px;
}

.reading-body img {
    max-width: 100%;
    height: auto;
}

.reading-attachments {
    border-top: 1px solid #e0e0e0;
    padding-top: 16px;
}

.attachment-item {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: #f1f3f4;
    border-radius: 8px;
    margin: 4px;
    font-size: 13px;
    color: #202124;
    transition: background 0.2s;
}

.attachment-item:hover {
    background: #e8eaed;
}

.attachment-size {
    color: #5f6368;
    font-size: 11px;
}

/* Compose Modal */
.compose-modal {
    position: fixed;
    bottom: 0;
    right: 24px;
    z-index: 300;
}

.compose-dialog {
    width: 500px;
    background: white;
    border-radius: 8px 8px 0 0;
    box-shadow: 0 8px 24px rgba(0,0,0,0.2);
    display: flex;
    flex-direction: column;
    max-height: 600px;
}

.compose-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    background: #404040;
    color: white;
    border-radius: 8px 8px 0 0;
    cursor: move;
}

.compose-header h3 {
    font-size: 14px;
    font-weight: 500;
}

.compose-header-actions {
    display: flex;
    gap: 4px;
}

.compose-header .btn-icon {
    color: white;
    width: 28px;
    height: 28px;
}

.compose-header .btn-icon:hover {
    background: rgba(255,255,255,0.1);
}

.compose-field {
    display: flex;
    align-items: center;
    padding: 8px 16px;
    border-bottom: 1px solid #e0e0e0;
}

.compose-field label {
    width: 50px;
    font-size: 13px;
    color: #5f6368;
    flex-shrink: 0;
}

.compose-field input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 13px;
    padding: 4px 0;
}

.compose-body {
    flex: 1;
    min-height: 200px;
}

.compose-editor {
    min-height: 200px;
    padding: 12px 16px;
    outline: none;
    font-size: 14px;
    line-height: 1.5;
}

.compose-attachments {
    padding: 8px 16px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.compose-attachment {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    background: #f1f3f4;
    border-radius: 6px;
    font-size: 12px;
}

.compose-attachment .remove-attachment {
    color: #5f6368;
    cursor: pointer;
}

.compose-attachment .remove-attachment:hover {
    color: #c5221f;
}

.compose-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 16px;
    border-top: 1px solid #e0e0e0;
}

.btn-send {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 20px;
    background: #1a73e8;
    color: white;
    border-radius: 16px;
    font-weight: 600;
    font-size: 14px;
    transition: background 0.2s;
}

.btn-send:hover {
    background: #1557b0;
}

.compose-actions-right {
    display: flex;
    gap: 4px;
}

/* Modals */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 400;
}

.modal-content {
    background: white;
    border-radius: 12px;
    padding: 24px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.2);
}

.modal-content h3 {
    margin-bottom: 16px;
    font-size: 18px;
}

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

.form-group input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #dadce0;
    border-radius: 4px;
    font-size: 14px;
}

.form-group input:focus {
    outline: none;
    border-color: #1a73e8;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.btn-secondary {
    padding: 8px 16px;
    background: #f1f3f4;
    color: #202124;
    border-radius: 4px;
    font-size: 13px;
}

.btn-secondary:hover {
    background: #e8eaed;
}

.btn-primary {
    padding: 8px 16px;
    background: #1a73e8;
    color: white;
    border-radius: 4px;
    font-size: 13px;
}

.btn-primary:hover {
    background: #1557b0;
}

/* Loading */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255,255,255,0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 500;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #e0e0e0;
    border-top-color: #1a73e8;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Toast */
.toast-container {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 600;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 12px 24px;
    background: #323232;
    color: white;
    border-radius: 8px;
    font-size: 14px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    animation: slideUp 0.3s ease;
}

.toast.success {
    background: #137333;
}

.toast.error {
    background: #c5221f;
}

@keyframes slideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Error Page */
.error-page {
    text-align: center;
    padding: 48px;
}

.error-page h1 {
    font-size: 72px;
    color: #5f6368;
    margin-bottom: 16px;
}

.error-page p {
    color: #5f6368;
    margin-bottom: 24px;
}

/* Responsive */
@media (max-width: 1024px) {
    .reading-pane {
        display: none;
    }
    
    .email-list-container {
        max-width: none;
    }
}

@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        top: 56px;
        left: 0;
        bottom: 0;
        z-index: 150;
        transform: translateX(-240px);
        box-shadow: 4px 0 12px rgba(0,0,0,0.1);
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .header-center {
        margin: 0 12px;
    }
    
    .logo {
        display: none;
    }
    
    .compose-dialog {
        width: 100%;
        max-width: none;
        right: 0;
        bottom: 0;
        left: 0;
        border-radius: 0;
    }
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #dadce0;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #bdc1c6;
}
