/* CSS Variables for Theming */
:root {
    /* Light Mode Colors */
    --bg-primary: #f5f5f5;
    --bg-secondary: #ffffff;
    --text-primary: #333333;
    --text-secondary: #666666;
    --border-color: #dddddd;
    --header-bg: #2e7d32;
    --header-text: #ffffff;
    --accent-color: #2e7d32;
    --accent-hover: #1b5e20;
    --shadow: rgba(0, 0, 0, 0.1);
    --input-bg: #ffffff;
    --input-border: #dddddd;
    --input-focus: #2e7d32;
}

[data-theme="dark"] {
    /* Dark Mode Colors */
    --bg-primary: #121212;
    --bg-secondary: #1e1e1e;
    --text-primary: #e0e0e0;
    --text-secondary: #a0a0a0;
    --border-color: #333333;
    --header-bg: #1a1a1a;
    --header-text: #e0e0e0;
    --accent-color: #4caf50;
    --accent-hover: #66bb6a;
    --shadow: rgba(0, 0, 0, 0.3);
    --input-bg: #2a2a2a;
    --input-border: #444444;
    --input-focus: #4caf50;
}

/* Core Layout and Typography */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Apply theme colors to inputs */
input, select, textarea {
    background: var(--input-bg);
    border-color: var(--input-border);
    color: var(--text-primary);
}

input:focus, select:focus, textarea:focus {
    border-color: var(--input-focus);
}

/* Cards and modals */
.card, .modal-content, .bg-white {
    background: var(--bg-secondary) !important;
    color: var(--text-primary);
}

/* Borders */
.border, .border-gray-200, .border-gray-300 {
    border-color: var(--border-color) !important;
}

/* Text colors */
.text-gray-700, .text-gray-900 {
    color: var(--text-primary) !important;
}

.text-gray-500, .text-gray-600 {
    color: var(--text-secondary) !important;
}

header {
    background: var(--header-bg);
    color: var(--header-text);
    padding: 1rem;
    box-shadow: 0 2px 4px var(--shadow);
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-controls {
    display: flex;
    gap: 10px;
    align-items: center;
}

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

/* Dark Mode Toggle Button */
.theme-toggle {
    background: none;
    border: none;
    color: var(--header-text);
    cursor: pointer;
    font-size: 24px;
    padding: 5px;
    border-radius: 4px;
    transition: background-color 0.3s;
}

.theme-toggle:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Tabs */
.tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    border-bottom: 2px solid var(--border-color);
    overflow-x: auto;
}

.tab {
    padding: 10px 20px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 16px;
    color: var(--text-secondary);
    transition: all 0.3s;
    white-space: nowrap;
}

.tab:hover {
    color: var(--text-primary);
}

.tab.active {
    color: var(--accent-color);
    border-bottom: 3px solid var(--accent-color);
}

.tab-content {
    display: none;
    animation: fadeIn 0.3s;
}

.tab-content.active {
    display: block;
}

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

/* Buttons */
button {
    background: var(--accent-color);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
    transition: background 0.3s;
}

button:hover {
    background: var(--accent-hover);
}

button.secondary {
    background: #757575;
}

button.secondary:hover {
    background: #616161;
}

/* Loading State */
.loading {
    text-align: center;
    padding: 40px;
    color: var(--text-secondary);
}

/* Responsive */
@media (max-width: 768px) {
    .tabs {
        overflow-x: scroll;
    }
}

/* Error Banner */
.error-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: #f44336;
    color: white;
    padding: 10px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 9999;
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        transform: translateY(-100%);
    }
    to {
        transform: translateY(0);
    }
}

.error-banner button {
    background: none;
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
    padding: 0;
    margin-left: 10px;
}

/* Logout button styles */
.logout-btn {
    background: #f44336;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    margin-left: 10px;
}

.logout-btn:hover {
    background: #d32f2f;
}

/* DYMO Printer Styles */
.dymo-print-btn {
    background: #7c3aed;
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.2s;
}

.dymo-print-btn:hover:not(:disabled) {
    background: #6d28d9;
}

.dymo-print-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.dymo-print-btn.small {
    padding: 4px 8px;
    font-size: 12px;
}

.dymo-status {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-left: 8px;
}

.dymo-status.connected {
    background: #10b981;
}

.dymo-status.disconnected {
    background: #ef4444;
}

.dymo-print-menu {
    position: relative;
    display: inline-block;
}

.dymo-template-menu {
    position: absolute;
    top: 100%;
    left: 0;
    background: white;
    border: 1px solid #ddd;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    z-index: 1000;
    min-width: 200px;
    margin-top: 4px;
}

.dymo-template-menu.hidden {
    display: none;
}

.template-menu-header {
    padding: 8px 12px;
    font-weight: 600;
    border-bottom: 1px solid #eee;
    background: #f9fafb;
}

.template-option {
    padding: 8px 12px;
    cursor: pointer;
    transition: background 0.2s;
}

.template-option:hover {
    background: #f3f4f6;
}

.template-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 12px;
    padding: 20px;
}

.template-card {
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    padding: 16px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
}

.template-card:hover {
    border-color: #7c3aed;
    background: #f3f0ff;
}

.template-icon {
    font-size: 32px;
    margin-bottom: 8px;
}

.template-name {
    font-size: 14px;
    font-weight: 500;
}

/* DYMO Settings Styles */
.settings-section {
    margin-bottom: 24px;
}

.settings-section h3 {
    color: #1f2937;
    margin-bottom: 12px;
    font-size: 18px;
}

.dymo-status-card {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 16px;
}

.status-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
}

.status-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}

.status-dot.connected {
    background: #10b981;
    animation: pulse 2s infinite;
}

.status-dot.disconnected {
    background: #ef4444;
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(16, 185, 129, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
    }
}

.button-row {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

.button-row button {
    flex: 1;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.secondary-btn {
    background: #e5e7eb;
    color: #374151;
    border: 1px solid #d1d5db;
}

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

.primary-btn {
    background: #7c3aed;
    color: white;
    border: none;
}

.primary-btn:hover {
    background: #6d28d9;
}

.primary-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.help-text {
    margin-top: 12px;
    color: #6b7280;
    font-size: 12px;
}

.settings-divider {
    border: none;
    border-top: 1px solid #e5e7eb;
    margin: 24px 0;
}

/* Enhanced Header DYMO Indicator */
.dymo-header-status {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    background: #f3f4f6;
    border-radius: 20px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.dymo-header-status:hover {
    background: #e5e7eb;
}

.dymo-header-status.connected {
    background: #dcfce7;
    color: #166534;
}

.dymo-header-status.disconnected {
    background: #fee2e2;
    color: #991b1b;
}

.dymo-header-status .status-text {
    font-weight: 500;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 9999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.5);
}

.modal-content {
    background-color: #fff;
    margin: 5% auto;
    padding: 20px;
    border-radius: 12px;
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

.settings-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid #e5e7eb;
}

.settings-header h2 {
    font-size: 24px;
    font-weight: 600;
    color: #111827;
}

.close-btn {
    background: none;
    border: none;
    font-size: 28px;
    color: #6b7280;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: all 0.2s;
}

.close-btn:hover {
    background: #f3f4f6;
    color: #111827;
}
