/* Reset e base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Light theme colors */
    --bg-primary: #f5f5f5;
    --bg-secondary: #fff;
    --bg-tertiary: #f4e4bc;
    --bg-quaternary: #f6e7bf;
    --text-primary: #333;
    --text-secondary: #666;
    --text-muted: #999;
    --border-primary: #ddd;
    --border-secondary: #7b4a16;
    --border-tertiary: #e3d2a7;
    --accent-primary: #7b4a16;
    --accent-secondary: #5a3a12;
    --shadow: rgba(0,0,0,0.1);
    --shadow-hover: rgba(0,0,0,0.15);
}

[data-theme="dark"] {
    /* Dark theme colors - Melhorado para melhor visibilidade */
    --bg-primary: #0d1117;
    --bg-secondary: #161b22;
    --bg-tertiary: #21262d;
    --bg-quaternary: #30363d;
    --text-primary: #e6edf3;
    --text-secondary: #c9d1d9;
    --text-muted: #8b949e;
    --border-primary: #30363d;
    --border-secondary: #8b5a2b;
    --border-tertiary: #21262d;
    --accent-primary: #8b5a2b;
    --accent-secondary: #6b4a1a;
    --shadow: rgba(0,0,0,0.5);
    --shadow-hover: rgba(0,0,0,0.6);
}

[data-theme="dark"] .raven-table {
    background: #161b22;
    color: #e6edf3;
}

[data-theme="dark"] .raven-table th {
    background: #21262d;
    color: #e6edf3;
    border-bottom: 1px solid #30363d;
}

[data-theme="dark"] .raven-table td {
    color: #e6edf3;
    border-bottom: 1px solid #30363d;
}

[data-theme="dark"] .raven-table tr:nth-child(even) td {
    background: #1c2128;
}

[data-theme="dark"] .raven-table tr:hover td {
    background: #262b33;
}

[data-theme="dark"] .row-player td {
    background: #21262d !important;
    color: #e6edf3;
}

[data-theme="dark"] .row-village td {
    background: #1c2128 !important;
    color: #e6edf3;
}

[data-theme="dark"] .table-container {
    background: #161b22;
    border: 1px solid #30363d;
}

[data-theme="dark"] .filters {
    background: #161b22;
    border: 1px solid #30363d;
}

[data-theme="dark"] .filter-input,
[data-theme="dark"] .filter-select {
    background: #0d1117;
    color: #e6edf3;
    border: 1px solid #30363d;
}

[data-theme="dark"] .filter-input:focus,
[data-theme="dark"] .filter-select:focus {
    border-color: #8b5a2b;
    background: #161b22;
}

[data-theme="dark"] .controls-row {
    background: #21262d;
    border: 1px solid #30363d;
}

[data-theme="dark"] .header {
    background: #161b22;
    border: 1px solid #30363d;
}

[data-theme="dark"] .status {
    color: #c9d1d9;
}

[data-theme="dark"] .badge {
    background: #21262d;
    border: 1px solid #30363d;
    color: #e6edf3;
}

[data-theme="dark"] .axe-panel {
    background: #161b22;
    border: 1px solid #30363d;
    color: #e6edf3;
}

[data-theme="dark"] .config-panel {
    background: #161b22;
    border: 1px solid #30363d;
    color: #e6edf3;
}

[data-theme="dark"] .config-panel h3 {
    color: #e6edf3;
}

[data-theme="dark"] .config-group input {
    background: #0d1117;
    color: #e6edf3;
    border: 1px solid #30363d;
}

[data-theme="dark"] .empty-state {
    color: #c9d1d9;
}

[data-theme="dark"] .command-colored {
    text-shadow: -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.4;
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Login Screen */
.login-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
}

.login-container {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 40px;
    box-shadow: 0 20px 40px var(--shadow);
    width: 100%;
    max-width: 400px;
    text-align: center;
    transition: background-color 0.3s ease, box-shadow 0.3s ease;
}

.login-header h1 {
    color: #2b1a0f;
    font-size: 28px;
    margin-bottom: 8px;
}

.login-header p {
    color: #666;
    font-size: 14px;
    margin-bottom: 30px;
}

.login-form {
    margin-bottom: 20px;
}

.form-group {
    margin-bottom: 20px;
    text-align: left;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #333;
}

.form-group input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e1e5e9;
    border-radius: 8px;
    font-size: 16px;
    transition: border-color 0.3s ease;
}

.form-group input:focus {
    outline: none;
    border-color: #7b4a16;
    box-shadow: 0 0 0 3px rgba(123, 74, 22, 0.1);
}

.login-btn {
    width: 100%;
    padding: 12px 24px;
    background: #7b4a16;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.3s ease;
    min-height: 44px;
    touch-action: manipulation;
}

.login-btn:hover {
    background: #5a3a12;
}

.login-btn:active {
    transform: translateY(1px);
}

.login-error {
    background: #fee;
    color: #c33;
    padding: 12px;
    border-radius: 6px;
    margin-top: 16px;
    font-size: 14px;
    border: 1px solid #fcc;
}

.login-footer {
    color: #666;
    font-size: 12px;
}

.login-footer p {
    margin: 0;
}

/* Main App */
.main-app {
    min-height: 100vh;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
.header {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-secondary);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 16px;
    box-shadow: 0 2px 4px var(--shadow);
    transition: background-color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

/* Tabs */
.tabs-row {
    display: flex;
    gap: 10px;
    margin: 10px 0;
    border-bottom: 2px solid var(--border-primary);
}

.tab-button {
    padding: 10px 20px;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: none;
    cursor: pointer;
    border-radius: 4px 4px 0 0;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
    min-height: 44px;
    touch-action: manipulation;
}

.tab-button:hover {
    background: var(--accent-primary);
    color: #fff;
}

.tab-button.active {
    background: var(--accent-primary);
    color: #fff;
    border-bottom: 2px solid var(--accent-primary);
    margin-bottom: -2px;
}

[data-theme="dark"] .tabs-row {
    border-bottom-color: #30363d;
}

[data-theme="dark"] .tab-button {
    background: #21262d;
    color: #e6edf3;
}

[data-theme="dark"] .tab-button:hover {
    background: #30363d;
}

[data-theme="dark"] .tab-button.active {
    background: #8b5a2b;
    color: #fff;
    border-bottom-color: #8b5a2b;
}

.header-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.header h1 {
    font-size: 24px;
    color: var(--text-primary);
    margin: 0;
    transition: color 0.3s ease;
}

.version-badge {
    background: var(--accent-primary);
    color: #fff;
    border-radius: 6px;
    padding: 4px 8px;
    font-size: 12px;
    margin-left: 8px;
    transition: background-color 0.3s ease;
}

.spacer {
    flex: 1;
}

.status {
    color: #4a3a22;
    font-size: 14px;
    font-weight: 500;
}

.collapse-btn {
    background: #333;
    color: #fff;
    border: none;
    border-radius: 4px;
    padding: 8px 12px;
    cursor: pointer;
    font-weight: bold;
    font-size: 14px;
    min-height: 44px;
    touch-action: manipulation;
}

.collapse-btn:hover {
    background: #555;
}

/* Theme Toggle */
.theme-toggle {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-secondary);
    border-radius: 6px;
    padding: 8px 12px;
    cursor: pointer;
    font-size: 18px;
    min-height: 44px;
    touch-action: manipulation;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.theme-toggle:hover {
    background: var(--accent-primary);
    color: #fff;
    transform: scale(1.05);
}

.theme-toggle:active {
    transform: scale(0.95);
}

/* Manual refresh button */
.manual-refresh-btn {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-secondary);
    border-radius: 6px;
    padding: 8px 12px;
    cursor: pointer;
    font-size: 18px;
    min-height: 44px;
    touch-action: manipulation;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.manual-refresh-btn:hover {
    background: var(--accent-primary);
    color: #fff;
    transform: scale(1.05);
}

.manual-refresh-btn:active {
    transform: scale(0.95);
}

.manual-refresh-btn.spinning {
    animation: spin 0.5s linear;
}

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

/* Last update indicator */
.last-update {
    font-size: 12px;
    color: var(--text-muted);
    padding: 0 8px;
    white-space: nowrap;
}

/* Botões de notificação removidos - agora via Tampermonkey */

/* Controls */
.controls-row {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
    background: #f6e7bf;
    border: 1px solid #e3d2a7;
    padding: 12px;
    border-radius: 6px;
}

.axe-filter {
    position: relative;
}

.axe-btn {
    background: #eee;
    border: 1px solid #888;
    border-radius: 6px;
    padding: 6px 12px;
    cursor: pointer;
    font-size: 12px;
    min-height: 44px;
    touch-action: manipulation;
}

.axe-btn:hover {
    background: #ddd;
}

.axe-panel {
    position: absolute;
    top: 100%;
    left: 0;
    background: #fbf3da;
    border: 1px solid #c9b27f;
    border-radius: 6px;
    padding: 12px;
    z-index: 1000;
    min-width: 280px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.axe-panel label {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 6px 0;
    font-size: 12px;
    cursor: pointer;
}

.axe-panel hr {
    border: none;
    border-top: 1px solid #e3d2a7;
    margin: 8px 0;
}

.control-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    cursor: pointer;
}

.control-label input[type="checkbox"] {
    transform: scale(1.1);
}

/* Stats */
.stats {
    display: flex;
    gap: 12px;
    align-items: center;
    margin: 16px 0;
    flex-wrap: wrap;
    overflow-x: auto;
    padding-bottom: 8px;
}

.badge {
    display: flex !important;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border: 1px solid #bbb;
    border-radius: 20px;
    background: #f8f8f8;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    flex-shrink: 0;
}

.badge img {
    height: 16px;
    width: 16px;
    image-rendering: pixelated;
}

.badge .stack {
    display: inline-flex;
    gap: 2px;
    align-items: center;
}

.badge .stack img {
    height: 14px;
    width: 14px;
}

/* Filters */
.filters {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
    background: #fff;
    padding: 16px;
    border-radius: 8px;
    border: 1px solid #ddd;
}

.filter-input, .filter-select {
    padding: 8px 12px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 14px;
    min-width: 150px;
}

.filter-input:focus, .filter-select:focus {
    outline: none;
    border-color: #7b4a16;
    box-shadow: 0 0 0 2px rgba(123, 74, 22, 0.2);
}

/* Table */
.table-container {
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.raven-table {
    width: 100%;
    border-collapse: collapse;
    background: #f4e4bc;
}

.raven-table th {
    background: #d2b48c;
    color: #2b1a0f;
    border-bottom: 1px solid #7b4a16;
    padding: 12px 8px;
    text-align: left;
    font-weight: 600;
    white-space: nowrap;
}

.raven-table td {
    padding: 8px;
    border-bottom: 1px solid #e3d2a7;
    white-space: nowrap;
    font-size: 13px;
}

.raven-table tr:nth-child(even) td {
    background: #f9f1d7;
}

.raven-table tr:hover td {
    background: #f0e6c7;
}

.axe-icon {
    height: 16px;
    width: 16px;
    image-rendering: pixelated;
}

/* Player/Village rows */
.row-player td {
    background: #edd9a8 !important;
    font-weight: 600;
}

.row-village td {
    background: #f6e7bf !important;
    font-weight: 500;
}

.row-ignored {
    opacity: 0.55;
}

/* Toggle buttons */
.toggle {
    cursor: pointer;
    user-select: none;
    padding: 0 8px;
    font-weight: bold;
    color: #7b4a16;
}

.toggle:hover {
    color: #5a3a12;
}

.label {
    font-weight: bold;
    margin-right: 8px;
}

/* Axe controls */
.axe-ctr {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-right: 8px;
}

.axe-ctr img {
    height: 16px;
    width: 16px;
    image-rendering: pixelated;
}

.axe-ctr .num {
    font-weight: bold;
    font-size: 12px;
}

/* Command colors */
.command-colored {
    font-weight: bold;
    text-shadow: -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000;
}

/* Countdown pills */
.raven-pill {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 6px;
    background: #333;
    color: #fff;
    font-size: 11px;
    font-weight: bold;
    border: 1px solid rgba(0,0,0,0.1);
    font-family: monospace;
}

.raven-pill.urgent {
    background: #b71c1c;
    color: #fff;
}

.raven-pill.warning {
    background: #ff9800;
    color: #fff;
}

.raven-pill.caution {
    background: #ffeb3b;
    color: #000;
}

/* Config panel */
.config-panel {
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 20px;
    margin-top: 20px;
}

.config-panel h3 {
    margin-bottom: 16px;
    color: #2b1a0f;
}

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

.config-group label {
    display: block;
    margin-bottom: 4px;
    font-weight: 500;
}

.config-group input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 14px;
}

.config-actions {
    display: flex;
    gap: 12px;
    margin-top: 20px;
}

.btn-primary, .btn-secondary {
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    min-height: 44px;
    touch-action: manipulation;
}

.btn-primary {
    background: #7b4a16;
    color: #fff;
}

.btn-primary:hover {
    background: #5a3a12;
}

.btn-secondary {
    background: #6c757d;
    color: #fff;
}

.btn-secondary:hover {
    background: #545b62;
}

/* Mobile First - Responsive Design */
@media (max-width: 480px) {
    /* Login Screen Mobile */
    .login-container {
        margin: 20px;
        padding: 30px 20px;
        border-radius: 8px;
    }
    
    .login-header h1 {
        font-size: 24px;
    }
    
    .login-header p {
        font-size: 13px;
    }
    
    .form-group input {
        font-size: 16px; /* Previne zoom no iOS */
        padding: 14px 16px;
    }
    
    .login-btn {
        padding: 14px 24px;
        font-size: 16px;
    }
    
    /* Main App Mobile */
    .container {
        padding: 8px;
    }
    
    .header {
        padding: 12px;
        margin-bottom: 12px;
    }
    
    .header-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    .header h1 {
        font-size: 20px;
    }
    
    .status {
        font-size: 12px;
        word-break: break-word;
    }
    
    .collapse-btn {
        padding: 10px 14px;
        font-size: 16px;
        min-height: 44px; /* Touch target size */
    }
    
    /* Controls Mobile */
    .controls-row {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
        padding: 16px;
    }
    
    .axe-filter {
        width: 100%;
    }
    
    .axe-btn {
        width: 100%;
        padding: 12px;
        font-size: 14px;
        min-height: 44px;
        text-align: left;
    }
    
    .axe-panel {
        position: fixed;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        width: 90vw;
        max-width: 320px;
        max-height: 80vh;
        overflow-y: auto;
        z-index: 10000;
    }
    
    .control-label {
        font-size: 14px;
        padding: 8px 0;
        min-height: 44px;
        display: flex;
        align-items: center;
    }
    
    .control-label input[type="checkbox"] {
        transform: scale(1.3);
        margin-right: 8px;
    }
    
    /* Stats Mobile */
    .stats {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
        margin: 12px 0;
    }
    
    .badge {
        justify-content: center;
        padding: 8px 12px;
        font-size: 13px;
        min-height: 44px;
    }
    
    /* Filters Mobile */
    .filters {
        flex-direction: column;
        gap: 12px;
        padding: 16px;
        margin-bottom: 12px;
    }
    
    .filter-input, .filter-select {
        width: 100%;
        min-width: auto;
        padding: 12px;
        font-size: 16px; /* Previne zoom no iOS */
        min-height: 44px;
        border-radius: 8px;
    }
    
    /* Table Mobile - Horizontal Scroll */
    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        border-radius: 8px;
        position: relative;
    }
    
    .table-container::after {
        content: "← Deslize para ver mais →";
        position: absolute;
        bottom: 5px;
        right: 10px;
        background: rgba(0,0,0,0.7);
        color: white;
        padding: 4px 8px;
        border-radius: 4px;
        font-size: 10px;
        pointer-events: none;
        opacity: 0.8;
    }
    
    .raven-table {
        min-width: 800px; /* Força scroll horizontal */
        font-size: 13px;
    }
    
    .raven-table th,
    .raven-table td {
        padding: 8px 6px;
        white-space: nowrap;
    }
    
    .raven-table th:first-child,
    .raven-table td:first-child {
        position: sticky;
        left: 0;
        background: inherit;
        z-index: 10;
    }
    
    /* Touch-friendly elements */
    .toggle {
        padding: 8px 12px;
        min-height: 44px;
        display: inline-flex;
        align-items: center;
        font-size: 14px;
    }
    
    .axe-ctr {
        min-height: 44px;
        padding: 4px 8px;
    }
    
    .axe-ctr img {
        height: 20px;
        width: 20px;
    }
    
    /* Config Panel Mobile */
    .config-panel {
        padding: 16px;
        margin-top: 16px;
    }
    
    .config-group input {
        padding: 12px;
        font-size: 16px;
        min-height: 44px;
    }
    
    .config-actions {
        flex-direction: column;
        gap: 12px;
    }
    
    .btn-primary, .btn-secondary {
        width: 100%;
        padding: 14px 20px;
        font-size: 16px;
        min-height: 44px;
    }
}

/* Tablet */
@media (min-width: 481px) and (max-width: 768px) {
    .container {
        padding: 12px;
    }
    
    .header-row {
        flex-wrap: wrap;
        gap: 12px;
    }
    
    .controls-row {
        flex-wrap: wrap;
        gap: 12px;
    }
    
    .filters {
        flex-wrap: wrap;
        gap: 12px;
    }
    
    .filter-input, .filter-select {
        min-width: 200px;
        flex: 1;
    }
    
    .raven-table {
        font-size: 12px;
    }
    
    .raven-table th,
    .raven-table td {
        padding: 8px 6px;
    }
}

/* Large Mobile / Small Tablet */
@media (min-width: 769px) and (max-width: 1024px) {
    .container {
        padding: 16px;
    }
    
    .filters {
        flex-wrap: wrap;
    }
    
    .filter-input, .filter-select {
        min-width: 180px;
    }
}

/* Hidden class */
.hidden {
    display: none !important;
}

/* Show ignored toggle */
html:not(.show-ignored) .row-ignored {
    display: none !important;
}

/* Loading States */
.loading-skeleton {
    background: var(--bg-secondary);
    border-radius: 8px;
    padding: 16px;
    margin: 16px 0;
}

.skeleton-row {
    height: 20px;
    background: linear-gradient(90deg, var(--bg-tertiary) 25%, var(--bg-quaternary) 50%, var(--bg-tertiary) 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
    border-radius: 4px;
    margin: 8px 0;
}

@keyframes loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Feedback Visual */
button:active, .btn-primary:active, .btn-secondary:active {
    transform: scale(0.95);
    transition: transform 0.1s ease;
}

.raven-table tr {
    transition: all 0.2s ease;
}

.raven-table tr:hover {
    transform: scale(1.01);
}

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

.empty-state p {
    font-size: 16px;
    margin-bottom: 16px;
}

.empty-state button {
    background: var(--accent-primary);
    color: #fff;
    border: none;
    padding: 12px 24px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.3s ease;
}

.empty-state button:hover {
    background: var(--accent-secondary);
}

/* Animações suaves */
.fade-in {
    animation: fadeIn 0.3s ease-in;
}

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

/* Melhorias de acessibilidade */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
