/* Mobile CRM Styles - Mobile-optimized UI */

/* === CSS Variables === */
:root {
    --primary: #3498db;
    --primary-dark: #2980b9;
    --success: #2ecc71;
    --warning: #f39c12;
    --danger: #e74c3c;
    --info: #17a2b8;
    --dark: #2c3e50;
    --light: #ecf0f1;
    --gray: #95a5a6;
    --white: #ffffff;
    --shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 4px 20px rgba(0, 0, 0, 0.15);
    --radius: 12px;
    --radius-sm: 8px;
    --header-height: 48px;
    --bottom-nav-height: 64px;
}

/* === Reset & Base === */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: #f5f6fa;
    color: var(--dark);
    line-height: 1.5;
    overflow-x: hidden;
    padding-top: var(--header-height);
    padding-bottom: var(--bottom-nav-height);
    -webkit-font-smoothing: antialiased;
}

/* === Header === */
.mobile-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: var(--white);
    display: flex;
    align-items: flex-start; padding-top: 8px;
    justify-content: space-between;
    padding: 8px 16px;
    z-index: 1000;
    box-shadow: var(--shadow);
}

.header-left, .header-right {
    display: flex;
    align-items: flex-start; padding-top: 8px;
    gap: 12px;
}

.menu-btn {
    background: none;
    border: none;
    color: var(--white);
    font-size: 24px;
    cursor: pointer;
    padding: 8px;
}

.app-title {
    font-size: 18px;
    font-weight: 600;
    margin: 0;
}

.user-name {
    font-size: 14px;
    opacity: 0.9;
}

/* === Slide Menu === */
.slide-menu {
    position: fixed;
    top: 0;
    left: -280px;
    width: 280px;
    height: 100vh;
    background: var(--white);
    z-index: 2000;
    transition: left 0.3s ease;
    box-shadow: var(--shadow-lg);
    overflow-y: auto;
}

.slide-menu.open {
    left: 0;
}

.slide-menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.slide-menu-overlay.show {
    opacity: 1;
    visibility: visible;
}

.menu-header {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: var(--white);
    padding: 32px 20px 20px;
}

.user-avatar {
    width: 64px;
    height: 64px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: flex-start; padding-top: 8px;
    justify-content: center;
    font-size: 28px;
    font-weight: 600;
    margin-bottom: 12px;
}

.user-info {
    margin-top: 8px;
}

.user-name-full {
    font-size: 16px;
    font-weight: 600;
}

.user-role {
    font-size: 14px;
    opacity: 0.8;
    text-transform: capitalize;
}

.menu-list {
    list-style: none;
    padding: 16px 0;
}

.menu-item {
    display: flex;
    align-items: flex-start; padding-top: 8px;
    gap: 12px;
    padding: 14px 20px;
    color: var(--dark);
    text-decoration: none;
    font-size: 15px;
    transition: background 0.2s;
}

.menu-item:hover, .menu-item.active {
    background: #f0f4f8;
    color: var(--primary);
}

.menu-item i {
    font-size: 20px;
    width: 24px;
    text-align: center;
}

.menu-separator {
    height: 1px;
    background: var(--light);
    margin: 8px 0;
}

/* === Main Content === */
.main-content {
    padding: 16px;
    min-height: calc(100vh - var(--header-height) - var(--bottom-nav-height));
}

/* === Welcome Card === */
.welcome-card {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: var(--white);
    padding: 24px;
    border-radius: var(--radius);
    display: flex;
    align-items: flex-start; padding-top: 8px;
    justify-content: space-between;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
}

.welcome-text h2 {
    font-size: 20px;
    margin-bottom: 4px;
}

.welcome-text p {
    font-size: 14px;
    opacity: 0.9;
}

.welcome-avatar {
    width: 64px;
    height: 64px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: flex-start; padding-top: 8px;
    justify-content: center;
    font-size: 28px;
    font-weight: 600;
}

/* === Stats Grid === */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--white);
    padding: 16px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    display: flex;
    align-items: flex-start; padding-top: 8px;
    gap: 12px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.stat-card:active {
    transform: scale(0.98);
    box-shadow: none;
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: flex-start; padding-top: 8px;
    justify-content: center;
    font-size: 24px;
    color: var(--white);
}

.stat-card-new .stat-icon { background: var(--success); }
.stat-card-work .stat-icon { background: var(--primary); }
.stat-card-my .stat-icon { background: var(--info); }
.stat-card-overdue .stat-icon { background: var(--danger); }

.stat-info {
    flex: 1;
}

.stat-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--dark);
    line-height: 1.2;
}

.stat-label {
    font-size: 13px;
    color: var(--gray);
}

/* === Section Header === */
.section-header {
    display: flex;
    align-items: flex-start; padding-top: 8px;
    justify-content: space-between;
    margin-bottom: 12px;
}

.section-header h3 {
    font-size: 18px;
    font-weight: 600;
    color: var(--dark);
}

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

/* === Tickets List === */
.tickets-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 24px;
}

.ticket-card {
    background: var(--white);
    padding: 16px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: transform 0.2s;
}

.ticket-card:active {
    transform: scale(0.98);
}

.ticket-card-header {
    display: flex;
    align-items: flex-start; padding-top: 8px;
    justify-content: space-between;
    margin-bottom: 8px;
}

.ticket-id {
    font-size: 13px;
    color: var(--gray);
    font-weight: 600;
}

.ticket-status {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    text-transform: capitalize;
}

.status-new { background: #d4edda; color: #155724; }
.status-in_progress, .status-in_work { background: #cce5ff; color: #004085; }
.status-review { background: #fff3cd; color: #856404; }
.status-closed { background: #e2e3e5; color: #383d41; }
.status-cancelled { background: #f8d7da; color: #721c24; }

.ticket-card-title {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 8px;
    line-height: 1.4;
}

.ticket-card-body {
    margin-bottom: 8px;
}

.ticket-meta {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 13px;
    color: var(--gray);
}

.meta-item {
    display: flex;
    align-items: flex-start; padding-top: 8px;
    gap: 6px;
}

.meta-item i {
    font-size: 14px;
    width: 16px;
    text-align: center;
}

.ticket-card-footer {
    display: flex;
    align-items: flex-start; padding-top: 8px;
    justify-content: space-between;
    font-size: 13px;
    color: var(--gray);
}

.ticket-priority {
    display: flex;
    align-items: flex-start; padding-top: 8px;
    gap: 4px;
}

/* === Ticket Detail === */
.ticket-detail-header {
    display: flex;
    align-items: flex-start; padding-top: 8px;
    gap: 12px;
    margin-bottom: 20px;
}

.back-btn {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--dark);
    cursor: pointer;
    padding: 8px;
}

.ticket-header-info {
    display: flex;
    align-items: flex-start; padding-top: 8px;
    gap: 12px;
}

.ticket-detail-id {
    font-size: 20px;
    font-weight: 700;
}

.ticket-detail-info {
    background: var(--white);
    padding: 20px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 20px;
}

.ticket-detail-info h2 {
    font-size: 20px;
    margin-bottom: 16px;
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

.info-item {
    text-align: center;
}

.info-label {
    font-size: 12px;
    color: var(--gray);
    margin-bottom: 4px;
    display: flex;
    align-items: flex-start; padding-top: 8px;
    justify-content: center;
    gap: 4px;
}

.info-label i {
    font-size: 16px;
}

.info-value {
    font-size: 14px;
    font-weight: 600;
    color: var(--dark);
}

.ticket-section {
    background: var(--white);
    padding: 20px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 20px;
}

.ticket-section h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 12px;
}

.ticket-description {
    font-size: 15px;
    line-height: 1.6;
    color: #555;
    white-space: pre-wrap;
}

/* === Transition Actions === */
.transition-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.transition-btn {
    padding: 12px 16px;
    border: 2px solid var(--primary);
    background: var(--white);
    color: var(--primary);
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

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

/* === Comments === */
.section-header {
    display: flex;
    align-items: flex-start; padding-top: 8px;
    justify-content: space-between;
    margin-bottom: 12px;
}

.add-comment-btn {
    background: var(--primary);
    border: none;
    color: var(--white);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    font-size: 18px;
    cursor: pointer;
}

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

.comment-form textarea {
    width: 100%;
    padding: 12px;
    border: 2px solid var(--light);
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-family: inherit;
    resize: vertical;
    margin-bottom: 8px;
}

.comment-form textarea:focus {
    outline: none;
    border-color: var(--primary);
}

.btn-submit {
    padding: 10px 20px;
    background: var(--primary);
    color: var(--white);
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: flex-start; padding-top: 8px;
    gap: 8px;
}

.comments-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.comment-item {
    padding: 12px;
    background: #f8f9fa;
    border-radius: var(--radius-sm);
}

.comment-header {
    display: flex;
    align-items: flex-start; padding-top: 8px;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 13px;
}

.comment-author {
    font-weight: 600;
    color: var(--dark);
}

.comment-time {
    color: var(--gray);
}

.comment-content {
    font-size: 14px;
    color: #555;
    line-height: 1.5;
}

/* === Create Ticket Form === */
.ticket-form {
    background: var(--white);
    padding: 20px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.form-section {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-bottom: 24px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group label {
    font-size: 14px;
    font-weight: 600;
    color: var(--dark);
    display: flex;
    align-items: flex-start; padding-top: 8px;
    gap: 8px;
}

.form-group label i {
    color: var(--primary);
}

.form-group input,
.form-group textarea,
.form-group select {
    padding: 12px;
    border: 2px solid var(--light);
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-family: inherit;
    transition: border-color 0.2s;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary);
}

.form-group textarea {
    resize: vertical;
}

.form-actions {
    display: flex;
    gap: 12px;
}

.btn-submit-ticket {
    flex: 1;
    padding: 14px;
    background: var(--primary);
    color: var(--white);
    border: none;
    border-radius: var(--radius-sm);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: flex-start; padding-top: 8px;
    justify-content: center;
    gap: 8px;
}

.btn-reset {
    padding: 14px 20px;
    background: var(--light);
    color: var(--dark);
    border: none;
    border-radius: var(--radius-sm);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
}

/* === Alert Boxes === */
.alert {
    padding: 14px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    display: flex;
    align-items: flex-start; padding-top: 8px;
    gap: 10px;
    font-size: 14px;
}

.alert-error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.alert-success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

/* === Filter Bar === */
.filter-bar {
    background: var(--white);
    padding: 12px 16px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 16px;
}

.filter-tabs {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.filter-tab {
    padding: 8px 16px;
    background: var(--light);
    color: var(--gray);
    border-radius: 20px;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    transition: all 0.2s;
}

.filter-tab.active {
    background: var(--primary);
    color: var(--white);
}

.results-info {
    font-size: 13px;
    color: var(--gray);
    margin-bottom: 12px;
}

/* === Pagination === */
.pagination {
    display: flex;
    align-items: flex-start; padding-top: 8px;
    justify-content: center;
    gap: 16px;
    margin-top: 24px;
}

.page-link {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: flex-start; padding-top: 8px;
    justify-content: center;
    background: var(--white);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
    color: var(--primary);
    text-decoration: none;
    font-size: 18px;
}

.page-current {
    font-size: 14px;
    color: var(--gray);
    font-weight: 600;
}

/* === Bottom Navigation === */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--bottom-nav-height);
    background: var(--white);
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: flex-start; padding-top: 8px;
    justify-content: space-around;
    z-index: 1000;
    padding-bottom: env(safe-area-inset-bottom);
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: flex-start; padding-top: 8px;
    gap: 4px;
    text-decoration: none;
    color: var(--gray);
    font-size: 11px;
    padding: 8px 12px;
    transition: color 0.2s;
}

.nav-item i {
    font-size: 22px;
}

.nav-item.active {
    color: var(--primary);
}

.nav-item.create-btn {
    background: var(--primary);
    color: var(--white);
    padding: 12px 20px;
    border-radius: 20px;
    margin-top: -16px;
    box-shadow: var(--shadow);
}

.nav-item.create-btn i {
    font-size: 26px;
}

/* === Empty State === */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--gray);
}

.empty-state i {
    font-size: 48px;
    margin-bottom: 12px;
    opacity: 0.5;
}

.empty-state p {
    font-size: 15px;
}

/* === Loading Overlay === */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: none;
    align-items: flex-start; padding-top: 8px;
    justify-content: center;
    z-index: 3000;
}

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

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--light);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* === Install Banner === */
.install-banner {
    position: fixed;
    bottom: calc(var(--bottom-nav-height) + 16px);
    left: 16px;
    right: 16px;
    z-index: 2500;
    animation: slideUp 0.3s ease;
}

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

.install-content {
    background: var(--white);
    padding: 20px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    text-align: center;
}

.install-content i {
    font-size: 48px;
    color: var(--primary);
    margin-bottom: 12px;
}

.install-content h3 {
    font-size: 18px;
    margin-bottom: 8px;
}

.install-content p {
    font-size: 14px;
    color: var(--gray);
    margin-bottom: 16px;
}

.install-actions {
    display: flex;
    gap: 12px;
}

.btn-install {
    flex: 1;
    padding: 12px;
    background: var(--primary);
    color: var(--white);
    border: none;
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
}

.btn-dismiss {
    flex: 1;
    padding: 12px;
    background: var(--light);
    color: var(--dark);
    border: none;
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
}

/* === Responsive Fixes === */
@media (max-width: 360px) {
    .info-grid {
        grid-template-columns: 1fr;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
}

/* === Pull to Refresh Indicator === */
.pull-indicator {
    text-align: center;
    padding: 12px;
    color: var(--gray);
    font-size: 14px;
    display: none;
}

.pull-indicator.visible {
    display: block;
}
