-- Staff date-specific schedule exceptions: full day off OR custom open/close hours.
-- Weekly pattern remains on staff_barbers.working_hours (Admin → Staff).

CREATE TABLE IF NOT EXISTS staff_time_off (
    id INT AUTO_INCREMENT PRIMARY KEY,
    tenant_id INT NOT NULL,
    staff_id INT NOT NULL,
    off_date DATE NOT NULL,
    is_day_off TINYINT(1) NOT NULL DEFAULT 1,
    open_time TIME NULL,
    close_time TIME NULL,
    reason VARCHAR(255) NULL,
    created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
    UNIQUE KEY uq_staff_off_day (staff_id, off_date),
    INDEX idx_time_off_tenant_date (tenant_id, off_date),
    FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON DELETE CASCADE,
    FOREIGN KEY (staff_id) REFERENCES staff_barbers(id) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
