/* ============================================
   AGENCY CRM - Google Sheet Style
   ============================================ */

:root {
    --primary: #1a73e8;
    --primary-dark: #1557b0;
    --sidebar-bg: #202124;
    --sidebar-text: #e8eaed;
    --bg: #f8f9fa;
    --white: #ffffff;
    --border: #dadce0;
    --text: #202124;
    --text-light: #5f6368;
    --success: #34a853;
    --warning: #fbbc04;
    --danger: #ea4335;
    --info: #4285f4;
    --row-hover: #e8f0fe;
    --header-bg: #f1f3f4;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: 'Google Sans', 'Segoe UI', Roboto, Arial, sans-serif; background: var(--bg); color: var(--text); font-size: 13px; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

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

/* Sidebar */
.sidebar {
    width: 240px;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    transition: transform 0.3s;
}
.sidebar-header { padding: 16px 20px; border-bottom: 1px solid #3c4043; }
.sidebar-header h2 { font-size: 18px; font-weight: 500; }
.sidebar-header h2 i { margin-right: 8px; color: var(--primary); }
.nav-menu { list-style: none; flex: 1; padding: 8px 0; overflow-y: auto; }
.nav-menu li a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 20px;
    color: var(--sidebar-text);
    font-size: 14px;
    transition: background 0.15s;
    position: relative;
}
.nav-menu li a:hover { background: #3c4043; text-decoration: none; }
.nav-menu li a.active { background: #3c4043; color: #8ab4f8; }
.nav-menu li a .badge {
    background: var(--danger);
    color: #fff;
    font-size: 11px;
    padding: 2px 6px;
    border-radius: 10px;
    margin-left: auto;
}
.sidebar-footer { padding: 12px 20px; border-top: 1px solid #3c4043; }
.user-info { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.user-info i { font-size: 28px; color: #8ab4f8; }
.user-info strong { display: block; font-size: 13px; }
.user-info small { color: #9aa0a6; font-size: 11px; }
.logout-btn { display: block; color: #f28b82; font-size: 13px; padding: 4px 0; }

/* Main Content */
.main-content { flex: 1; margin-left: 240px; display: flex; flex-direction: column; }
.top-bar {
    background: var(--white);
    border-bottom: 1px solid var(--border);
    padding: 8px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 50;
}
.sidebar-toggle { display: none; background: none; border: none; font-size: 20px; cursor: pointer; color: var(--text); }
.top-bar-right { display: flex; align-items: center; gap: 16px; }
.notification-bell { position: relative; cursor: pointer; font-size: 18px; }
.notification-bell .badge {
    position: absolute;
    top: -6px;
    right: -8px;
    background: var(--danger);
    color: #fff;
    font-size: 10px;
    padding: 1px 5px;
    border-radius: 10px;
}
.user-name { font-weight: 500; font-size: 13px; }
.content-area { padding: 20px 24px; flex: 1; }

/* Notification Panel */
.notif-panel {
    position: fixed;
    right: 20px;
    top: 50px;
    width: 360px;
    max-height: 500px;
    overflow-y: auto;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
    z-index: 200;
    padding: 16px;
}
.notif-panel h3 { margin-bottom: 12px; font-size: 16px; }
.notif-item {
    padding: 10px 12px;
    border-left: 4px solid var(--info);
    background: #f8f9fa;
    margin-bottom: 8px;
    border-radius: 4px;
}
.notif-item strong { display: block; margin-bottom: 4px; }
.notif-item p { color: var(--text-light); font-size: 12px; }
.notif-item small { color: #9aa0a6; }
.notif-warning { border-left-color: var(--warning); }
.notif-danger { border-left-color: var(--danger); }
.empty-msg { color: var(--text-light); text-align: center; padding: 20px; }

/* Page Title */
.page-title { font-size: 20px; font-weight: 500; margin-bottom: 16px; }

/* ============================================
   SHEET-STYLE TABLE (Dashboard)
   ============================================ */
.sheet-controls {
    display: flex;
    gap: 10px;
    margin-bottom: 12px;
    flex-wrap: wrap;
    align-items: center;
}
.sheet-controls input, .sheet-controls select {
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 13px;
    background: var(--white);
}
.sheet-controls input[type="text"] { width: 220px; }
.sheet-controls .btn { margin-left: auto; }

.sheet-wrapper { overflow-x: auto; border: 1px solid var(--border); border-radius: 4px; background: var(--white); }
.sheet-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 1400px;
}
.sheet-table th {
    background: var(--header-bg);
    border: 1px solid var(--border);
    padding: 8px 10px;
    font-weight: 500;
    font-size: 12px;
    text-transform: uppercase;
    color: var(--text-light);
    position: sticky;
    top: 0;
    white-space: nowrap;
}
.sheet-table td {
    border: 1px solid var(--border);
    padding: 6px 10px;
    font-size: 13px;
    vertical-align: middle;
}
.sheet-table tr:hover { background: var(--row-hover); }
.sheet-table tr.dragging { opacity: 0.5; background: #c8e6c9; }
.sheet-table .drag-handle { cursor: grab; color: var(--text-light); padding: 0 4px; }
.sheet-table .drag-handle:active { cursor: grabbing; }

/* Status Badge */
.status-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 500;
    color: #fff;
    white-space: nowrap;
}
.status-badge.light-text { color: #333; }

/* Priority */
.priority-normal { color: var(--text-light); }
.priority-urgent { color: var(--danger); font-weight: 600; }

/* Deadline indicator */
.deadline-indicator {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    font-weight: 500;
    padding: 2px 8px;
    border-radius: 10px;
    color: #fff;
}

/* Action buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 16px;
    border: none;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s, box-shadow 0.15s;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); box-shadow: 0 1px 3px rgba(0,0,0,0.2); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-success { background: var(--success); color: #fff; }
.btn-warning { background: var(--warning); color: #333; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover { background: var(--header-bg); }
.btn-icon { background: none; border: none; cursor: pointer; color: var(--text-light); padding: 4px; font-size: 16px; }
.btn-icon:hover { color: var(--primary); }

/* ============================================
   FORMS
   ============================================ */
.form-card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 24px;
    max-width: 900px;
}
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}
.form-group { margin-bottom: 14px; }
.form-group.full-width { grid-column: 1 / -1; }
.form-group label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-light);
    margin-bottom: 4px;
    text-transform: uppercase;
}
.form-group input, .form-group select, .form-group textarea {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 13px;
    font-family: inherit;
    transition: border 0.2s;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(26,115,232,0.15);
}
.form-group textarea { resize: vertical; min-height: 60px; }
.form-section-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    margin: 20px 0 10px;
    padding-bottom: 6px;
    border-bottom: 2px solid var(--primary);
    grid-column: 1 / -1;
}

/* ============================================
   TRELLO-STYLE BOARD
   ============================================ */
.board-container { display: flex; gap: 16px; overflow-x: auto; padding-bottom: 16px; }
.board-column {
    min-width: 280px;
    max-width: 300px;
    background: var(--header-bg);
    border-radius: 8px;
    padding: 12px;
    flex-shrink: 0;
}
.board-column-title {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--border);
    display: flex;
    align-items: center;
    gap: 6px;
}
.board-column-title .count {
    background: var(--border);
    padding: 1px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 400;
}
.board-card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 12px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: box-shadow 0.15s;
}
.board-card:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.1); }
.board-card .card-title { font-weight: 500; font-size: 13px; margin-bottom: 6px; }
.board-card .card-meta { font-size: 11px; color: var(--text-light); margin-bottom: 4px; }
.board-card .card-meta i { margin-right: 4px; }
.card-progress {
    height: 4px;
    background: #e0e0e0;
    border-radius: 2px;
    margin-top: 8px;
    overflow: hidden;
}
.card-progress-bar { height: 100%; background: var(--success); border-radius: 2px; transition: width 0.3s; }

/* To Do column */
.board-column.col-todo .board-column-title { border-bottom-color: #90a4ae; }
.board-column.col-progress .board-column-title { border-bottom-color: var(--primary); }
.board-column.col-completed .board-column-title { border-bottom-color: var(--success); }
.board-column.col-revision .board-column-title { border-bottom-color: var(--warning); }
.board-column.col-revision-done .board-column-title { border-bottom-color: #66bb6a; }

/* ============================================
   CHAT
   ============================================ */
.chat-layout { display: flex; gap: 0; height: calc(100vh - 120px); border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: var(--white); }
.chat-sidebar {
    width: 280px;
    border-right: 1px solid var(--border);
    overflow-y: auto;
    background: #f8f9fa;
}
.chat-sidebar-item {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background 0.1s;
}
.chat-sidebar-item:hover, .chat-sidebar-item.active { background: #e8f0fe; }
.chat-sidebar-item strong { display: block; font-size: 13px; }
.chat-sidebar-item small { color: var(--text-light); }
.chat-main { flex: 1; display: flex; flex-direction: column; }
.chat-header { padding: 12px 16px; border-bottom: 1px solid var(--border); background: var(--header-bg); font-weight: 500; }
.chat-messages { flex: 1; overflow-y: auto; padding: 16px; }
.chat-msg { margin-bottom: 12px; max-width: 70%; }
.chat-msg.sent { margin-left: auto; }
.chat-msg .msg-bubble {
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 13px;
    line-height: 1.5;
}
.chat-msg.received .msg-bubble { background: #f1f3f4; }
.chat-msg.sent .msg-bubble { background: #d2e3fc; }
.chat-msg .msg-info { font-size: 10px; color: var(--text-light); margin-top: 2px; }
.chat-msg .msg-mention { color: var(--primary); font-weight: 500; }
.chat-input-area {
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 8px;
    align-items: center;
}
.chat-input-area select { width: 160px; }
.chat-input-area input[type="text"] { flex: 1; padding: 8px 12px; border: 1px solid var(--border); border-radius: 20px; font-size: 13px; }
.chat-input-area button { padding: 8px 16px; }

/* ============================================
   CHANNEL MANAGEMENT
   ============================================ */
.channel-table { width: 100%; border-collapse: collapse; background: var(--white); border: 1px solid var(--border); border-radius: 4px; }
.channel-table th { background: var(--header-bg); }
.channel-table th, .channel-table td { padding: 8px 12px; border: 1px solid var(--border); font-size: 13px; }
.channel-table select { padding: 4px 8px; border: 1px solid var(--border); border-radius: 4px; }

/* ============================================
   FINANCE MODULE
   ============================================ */
.finance-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.finance-card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px;
    text-align: center;
}
.finance-card .value { font-size: 28px; font-weight: 600; color: var(--primary); }
.finance-card .label { font-size: 12px; color: var(--text-light); margin-top: 4px; text-transform: uppercase; }
.finance-card.profit .value { color: var(--success); }
.finance-card.cost .value { color: var(--danger); }

/* ============================================
   KPI
   ============================================ */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.kpi-card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 20px;
    text-align: center;
}
.kpi-card .kpi-value { font-size: 36px; font-weight: 700; }
.kpi-card .kpi-label { font-size: 12px; color: var(--text-light); margin-top: 4px; }
.kpi-card.kpi-success .kpi-value { color: var(--success); }
.kpi-card.kpi-warning .kpi-value { color: var(--warning); }
.kpi-card.kpi-danger .kpi-value { color: var(--danger); }

/* ============================================
   LOGIN PAGE
   ============================================ */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}
.login-card {
    background: var(--white);
    border-radius: 12px;
    padding: 40px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}
.login-card h1 { text-align: center; margin-bottom: 8px; font-size: 24px; }
.login-card p { text-align: center; color: var(--text-light); margin-bottom: 24px; }
.login-card .form-group { margin-bottom: 16px; }
.login-card .form-group label { font-size: 13px; }
.login-card .form-group input { padding: 10px 12px; font-size: 14px; }
.login-card .btn { width: 100%; justify-content: center; padding: 10px; font-size: 14px; }
.login-error { background: #fce4ec; color: var(--danger); padding: 8px 12px; border-radius: 4px; font-size: 13px; margin-bottom: 12px; }

/* ============================================
   PROJECT DETAIL MODAL / PAGE
   ============================================ */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 300;
    display: flex;
    align-items: center;
    justify-content: center;
}
.modal-content {
    background: var(--white);
    border-radius: 8px;
    width: 90%;
    max-width: 800px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 24px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.3);
}
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.modal-close { font-size: 24px; cursor: pointer; color: var(--text-light); background: none; border: none; }

/* Subtask table */
.subtask-table { width: 100%; border-collapse: collapse; margin-top: 12px; }
.subtask-table th, .subtask-table td { padding: 8px 10px; border: 1px solid var(--border); font-size: 13px; }
.subtask-table th { background: var(--header-bg); font-weight: 500; }
.subtask-table select, .subtask-table input { padding: 4px 6px; border: 1px solid var(--border); border-radius: 3px; font-size: 12px; width: 100%; }

/* Alerts */
.alert { padding: 10px 14px; border-radius: 4px; margin-bottom: 12px; font-size: 13px; }
.alert-success { background: #e8f5e9; color: #2e7d32; border: 1px solid #a5d6a7; }
.alert-error { background: #fce4ec; color: #c62828; border: 1px solid #ef9a9a; }
.alert-warning { background: #fff3e0; color: #e65100; border: 1px solid #ffcc80; }
.alert-info { background: #e3f2fd; color: #1565c0; border: 1px solid #90caf9; }

/* ============================================
   PROJECT DETAIL PAGE
   ============================================ */
.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}
.detail-item label {
    font-size: 11px;
    color: var(--text-light);
    text-transform: uppercase;
    display: block;
}
.detail-item .val {
    font-size: 14px;
    font-weight: 500;
}

/* Tabs */
.tabs { display: flex; gap: 0; border-bottom: 2px solid var(--border); margin-bottom: 16px; }
.tab-btn {
    padding: 10px 20px;
    border: none;
    background: none;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    color: var(--text-light);
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: color 0.15s, border-color 0.15s;
}
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .sidebar-toggle { display: block; }
    .main-content { margin-left: 0; }
    .form-grid { grid-template-columns: 1fr; }
    .sheet-controls { flex-direction: column; }
    .sheet-controls input[type="text"] { width: 100%; }
    .detail-grid { grid-template-columns: 1fr; }
    .chat-sidebar { width: 200px; }
}

/* Dropdown status in cells */
.status-select {
    padding: 4px 8px;
    border-radius: 12px;
    border: none;
    font-size: 11px;
    font-weight: 500;
    color: #fff;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='5'%3E%3Cpath d='M0 0l4 5 4-5z' fill='white'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    padding-right: 22px;
}

/* Links */
.link-cell a { color: var(--primary); font-size: 12px; }
.link-cell a:hover { text-decoration: underline; }

/* Team member avatars */
.avatar-small {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    background: var(--primary);
    color: #fff;
    border-radius: 50%;
    font-size: 10px;
    font-weight: 600;
}

/* Select2-like multi-select */
.multi-select-display {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}
.multi-tag {
    background: #e3f2fd;
    color: var(--primary);
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
}
