/**
 * Baud9600 Network Tools - Common Design System
 * Shared styles for consistent UX across all calculator tools
 */

:root {
    /* Color Palette */
    --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --primary-color: #667eea;
    --primary-dark: #764ba2;
    --success-color: #4CAF50;
    --warning-color: #ffc107;
    --error-color: #dc3545;
    --info-color: #17a2b8;
    --neutral-bg: #f8f9fa;
    --neutral-border: #e0e0e0;
    --text-primary: #333;
    --text-secondary: #6c757d;
    --white: #ffffff;

    /* Shadows */
    --shadow-sm: 0 2px 4px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.1);
    --shadow-lg: 0 6px 12px rgba(0,0,0,0.15);
    --shadow-focus: 0 0 0 3px rgba(76, 175, 80, 0.1);

    /* Border Radius */
    --radius-sm: 4px;
    --radius-md: 6px;
    --radius-lg: 8px;
    --radius-xl: 12px;

    /* Spacing */
    --space-xs: 5px;
    --space-sm: 10px;
    --space-md: 15px;
    --space-lg: 20px;
    --space-xl: 30px;

    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-medium: 0.3s ease;
    --transition-slow: 0.5s ease;

    /* Typography */
    --font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    --font-mono: 'Courier New', Monaco, monospace;
    --font-size-sm: 13px;
    --font-size-base: 14px;
    --font-size-md: 16px;
    --font-size-lg: 20px;
    --font-size-xl: 28px;
}

/* Global Resets */
* {
    box-sizing: border-box;
}

body {
    font-family: var(--font-family);
    margin: 0;
    padding: 0;
    color: var(--text-primary);
    line-height: 1.6;
}

/* Container */
.calc-container {
    max-width: 1200px;
    margin: 20px auto;
    padding: var(--space-lg);
}

/* Header */
.calc-header {
    margin-bottom: var(--space-xl);
    padding: 25px;
    background: var(--primary-gradient);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-md);
    color: var(--white);
}

.calc-header h2 {
    margin-top: 0;
    color: var(--white);
    font-size: var(--font-size-xl);
    margin-bottom: var(--space-sm);
}

.calc-header p {
    margin: var(--space-sm) 0 var(--space-lg) 0;
    opacity: 0.95;
    font-size: 15px;
}

/* Sections */
.section {
    background: var(--white);
    border: 1px solid var(--neutral-border);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    margin-bottom: var(--space-xl);
    box-shadow: var(--shadow-sm);
}

.section-title {
    margin-top: 0;
    margin-bottom: var(--space-lg);
    color: var(--text-primary);
    border-left: 5px solid var(--primary-color);
    padding-left: var(--space-md);
    font-size: var(--font-size-lg);
}

/* Input Groups */
.input-group {
    display: flex;
    flex-direction: column;
    margin-bottom: var(--space-md);
}

.input-group label {
    margin-bottom: 8px;
    font-weight: 600;
    font-size: var(--font-size-base);
    color: var(--text-primary);
}

.input-group input,
.input-group select,
.input-group textarea {
    padding: 12px;
    font-size: var(--font-size-md);
    border: 2px solid #ced4da;
    border-radius: var(--radius-md);
    transition: all var(--transition-medium);
    font-family: var(--font-family);
}

.input-group input:focus,
.input-group select:focus,
.input-group textarea:focus {
    outline: none;
    border-color: var(--success-color);
    box-shadow: var(--shadow-focus);
}

/* Buttons */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius-md);
    font-size: var(--font-size-md);
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-medium);
    box-shadow: var(--shadow-sm);
    font-family: var(--font-family);
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn:active {
    transform: translateY(0);
}

.btn-primary {
    background: var(--success-color);
    color: var(--white);
}

.btn-primary:hover {
    background: #45a049;
}

.btn-secondary {
    background: #6c757d;
    color: var(--white);
}

.btn-secondary:hover {
    background: #5a6268;
}

.btn-small {
    padding: 8px 16px;
    font-size: var(--font-size-sm);
}

/* Alerts */
.alert {
    padding: 15px 20px;
    border-radius: var(--radius-lg);
    margin-bottom: var(--space-lg);
    border-left: 4px solid;
}

.alert-info {
    background: #d1ecf1;
    border-color: var(--info-color);
    color: #0c5460;
}

.alert-warning {
    background: #fff3cd;
    border-color: var(--warning-color);
    color: #856404;
}

.alert-success {
    background: #d4edda;
    border-color: var(--success-color);
    color: #155724;
}

.alert-error {
    background: #f8d7da;
    border-color: var(--error-color);
    color: #721c24;
}

/* Cards */
.card {
    background: var(--white);
    border: 1px solid var(--neutral-border);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    box-shadow: var(--shadow-sm);
    transition: all var(--transition-medium);
}

.card:hover {
    box-shadow: var(--shadow-md);
}

/* Result Cards */
.result-card {
    background: var(--neutral-bg);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    margin-bottom: var(--space-md);
    border-left: 5px solid var(--primary-color);
}

.result-card.success {
    border-left-color: var(--success-color);
}

.result-card.warning {
    border-left-color: var(--warning-color);
}

.result-card.error {
    border-left-color: var(--error-color);
}

.result-label {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    margin-bottom: var(--space-xs);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

.result-value {
    font-size: 42px;
    font-weight: bold;
    font-family: var(--font-mono);
    color: var(--text-primary);
}

/* Tooltips */
.tooltip-trigger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    background: var(--info-color);
    color: var(--white);
    border-radius: 50%;
    font-size: 12px;
    font-weight: bold;
    cursor: help;
    margin-left: 6px;
    position: relative;
}

.tooltip-trigger:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 125%;
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: var(--white);
    padding: 8px 12px;
    border-radius: var(--radius-md);
    font-size: var(--font-size-sm);
    font-weight: normal;
    white-space: nowrap;
    z-index: 1000;
    box-shadow: var(--shadow-lg);
}

.tooltip-trigger:hover::before {
    content: '';
    position: absolute;
    bottom: 115%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: #333;
    z-index: 1000;
}

/* How to Use Panel */
.how-to-use {
    background: var(--neutral-bg);
    border: 2px solid var(--neutral-border);
    border-radius: var(--radius-lg);
    margin-bottom: var(--space-xl);
    overflow: hidden;
}

.how-to-use-header {
    background: var(--white);
    padding: var(--space-md);
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
    transition: background var(--transition-fast);
}

.how-to-use-header:hover {
    background: var(--neutral-bg);
}

.how-to-use-content {
    padding: var(--space-lg);
    display: none;
}

.how-to-use-content.active {
    display: block;
}

.how-to-use-content ul {
    margin: 0;
    padding-left: 20px;
}

.how-to-use-content li {
    margin-bottom: var(--space-sm);
}

/* Hidden Utility */
.hidden {
    display: none !important;
}

/* Loading State */
.loading-spinner {
    display: inline-block;
    width: 40px;
    height: 40px;
    border: 4px solid var(--neutral-bg);
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Fade In Animation */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in {
    animation: fadeIn 0.3s ease forwards;
}

/* Responsive Design */
@media (max-width: 768px) {
    .calc-container {
        padding: var(--space-sm);
    }

    .calc-header h2 {
        font-size: 24px;
    }

    .result-value {
        font-size: 32px;
    }

    .btn {
        width: 100%;
        margin-bottom: var(--space-sm);
    }

    .tooltip-trigger:hover::after {
        white-space: normal;
        max-width: 200px;
    }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Focus Visible (for keyboard navigation) */
:focus-visible {
    outline: 3px solid var(--primary-color);
    outline-offset: 2px;
}

/* Session Persistence UI */
.session-controls {
    background: var(--neutral-bg);
    border: 1px solid var(--neutral-border);
    border-radius: var(--radius-md);
    padding: var(--space-sm);
    margin-bottom: var(--space-lg);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: var(--font-size-sm);
}

.session-status {
    color: var(--text-secondary);
}

.session-status.saved {
    color: var(--success-color);
}

/* Print Styles */
@media print {
    .calc-header,
    .btn,
    .how-to-use,
    .session-controls {
        display: none;
    }

    .section {
        page-break-inside: avoid;
    }
}
